/// <summary> /// Registers for push notifications. /// </summary> public void RegisterForPushNotifications() { if (Application.platform == RuntimePlatform.Android) { #if UNITY_ANDROID && !UNITY_EDITOR ddnaNotifications.Register( new AndroidJavaClass("com.unity3d.player.UnityPlayer") .GetStatic <AndroidJavaObject>("currentActivity")); #endif } }
/// <summary> /// Registers for push notifications. /// /// If you have multiple Firebase Cloud Messaging senders in your project /// then you can use the deltaDNA sender either as a main one or as a /// secondary one by setting the secondary parameter. If you set secondary /// to true then the default FCM sender will need to have been initialised /// beforehand. /// /// In the case when the app is already registered for push notifications /// and the registration id is up to date then the callbacks will not be /// invoked. /// </summary> /// <param name="secondary">Whether the Firebase instance used for the /// deltaDNA notifications should be registered as a secondary (non-main) /// instance.</param> public void RegisterForPushNotifications(bool secondary = false) { if (Application.platform == RuntimePlatform.Android && AreNotificationsPresent()) { #if UNITY_ANDROID && !UNITY_EDITOR try { ddnaNotifications.Register( new AndroidJavaClass("com.unity3d.player.UnityPlayer") .GetStatic <AndroidJavaObject>("currentActivity"), secondary); } catch (AndroidJavaException e) { Logger.LogWarning("Failed to register for push notifications. Notifications may not be configured correctly. " + e.Message); } #endif } }