Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        //PlayerSettings.statusBarHidden = false;
        Screen.fullScreen = false;

        if (!PlayerPrefs.HasKey("isPush"))
        {
            FirebaseMessaging.Subscribe("Notification");
            PlayerPrefs.SetInt("isPush", 1);
        }
    }
Beispiel #2
0
        private void RegisterForToken()
        {
            if (mIsFetchingToken)
            {
                return;
            }

            mIsFetchingToken = true;

            if (!Application.isMobilePlatform || Application.isEditor)
            {
                SetDebugText("Platform unsupported for push noticiations");
            }
            else
            {
                SetDebugText("Register for token - Begin");

#if UNITY_ANDROID || UNITY_EDITOR
                // Firebase is dependant on Google Services. Prompt user to install/update if unavailable.
                FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(
                    task =>
                {
                    DependencyStatus dependencyStatus = task.Result;

                    if (dependencyStatus == DependencyStatus.Available)
                    {
                        FirebaseMessaging.TokenReceived += OnGetFirebaseToken;
                        FirebaseMessaging.Subscribe("TestTopic");
                    }
                    else
                    {
                        OnRegisterFail("Could not resolve all Firebase dependencies: " + dependencyStatus);
                    }
                });
#endif

#if UNITY_IPHONE || UNITY_EDITOR
                NotificationServices.RegisterForNotifications(
                    NotificationType.Alert |
                    NotificationType.Badge |
                    NotificationType.Sound);

                StartCoroutine(WaitForIOSToken());
#endif
                SetDebugText("Register for token - Waiting");
            }
        }
Beispiel #3
0
 public static void Subscribe(string topic)
 {
             #if messaging
     FirebaseMessaging.Subscribe(topic);
             #endif
 }