Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using System.Net;
  5. using Facebook.Unity;
  6. using UnityEngine;
  7. using WebView;
  8.  
  9. public class Core : MonoBehaviour
  10. {
  11.     private void InitCallback()
  12.     {
  13.         if (FB.IsInitialized)
  14.         {
  15.             FB.ActivateApp();
  16.             CheckGameServer();
  17.         }
  18.         else
  19.         {
  20.             Debug.Log("Failed to Initialize the Facebook SDK");
  21.         }
  22.     }
  23.  
  24.     private void OnHideUnity(bool isGameShown)
  25.     {
  26.         Time.timeScale = isGameShown ? 1 : 0;
  27.     }
  28.  
  29.     private void Awake()
  30.     {
  31.         OneSignal.StartInit(OneSignalKey)
  32.             .HandleNotificationOpened(HandleNotificationOpened)
  33.             .EndInit();
  34.  
  35.         OneSignal.inFocusDisplayType = OneSignal.OSInFocusDisplayOption.Notification;
  36.  
  37.         if (!FB.IsInitialized)
  38.         {
  39.             FB.Init(InitCallback, OnHideUnity);
  40.         }
  41.         else
  42.         {
  43.             FB.ActivateApp();
  44.             CheckGameServer();
  45.         }
  46.     }
  47.  
  48.     private void DeepLinkCallback(IAppLinkResult appLinkResult)
  49.     {
  50.         Debug.Log($"DeepLinkCallback {appLinkResult}");
  51.         RunGameCore(appLinkResult.Url);
  52.     }
  53.  
  54.     private void CheckGameServer()
  55.     {
  56.         FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement