Beispiel #1
0
 public static void RemoveNotificationChannel(string channelId)
 {
     if (PusheAndroidUtils.SdkLevel() >= 26)
     {
         PusheAndroidUtils.PusheNotificationService().Call("removeNotificationChannel", channelId);
     }
     else
     {
         Debug.Log("Lower than android 8.0. No channel to remove :|");
     }
 }
Beispiel #2
0
        public static NotificationButtonData FromAndroid(AndroidJavaObject androidJavaObject)
        {
            NotificationButtonData button = new NotificationButtonData();

            try {
                string json = PusheAndroidUtils.Extension("notification").CallStatic <string>("notificationButtonToJson", androidJavaObject);
                button = JsonUtility.FromJson <NotificationButtonData>(json);
            } catch (Exception e) {
                PusheUnity.Log("Failed to parse notification " + e);
            }
            return(button);
        }
Beispiel #3
0
        public static InAppMessage FromAndroid(AndroidJavaObject androidObject)
        {
            var inapp = new InAppMessage();

            try {
                var inappJson = PusheAndroidUtils.Extension("inappmessaging").CallStatic <string>("inAppToJson", androidObject);
                inapp = JsonUtility.FromJson <InAppMessage>(inappJson);
            } catch (Exception e) {
                PusheUnity.Log("Failed to parse inapp message.\n" + e);
            }
            return(inapp);
        }
Beispiel #4
0
 /// <summary>
 /// For API 26 and above you can create channel for your app.
 /// Please refer to android official docs for more information
 ///
 /// NOTE: If lower than 26, nothing will happen.
 /// </summary>
 public static void CreateNotificationChannel(
     string channelId,
     string channelName,
     string description      = "",
     int importance          = 4,
     bool enableLight        = true,
     bool enableVibration    = true,
     long[] vibrationLengths = null,
     bool showBadge          = true,
     int ledColor            = 0
     )
 {
     if (PusheAndroidUtils.SdkLevel() >= 26)
     {
         PusheAndroidUtils.PusheNotificationService().Call("createNotificationChannel", channelId, channelName,
                                                           description, importance, enableLight, enableVibration, showBadge, ledColor, vibrationLengths);
     }
     else
     {
         Debug.Log("Lower than android 8.0. Channel not created!");
     }
 }
Beispiel #5
0
 public static void DisableNotificationForceForegroundAware()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableNotificationForceForegroundAware");
 }
Beispiel #6
0
 public static AndroidJavaObject PusheAnalyticsService()
 {
     return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "analytics"));
 }
Beispiel #7
0
 public static AndroidJavaObject PusheNotificationService()
 {
     return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "notification"));
 }
Beispiel #8
0
        public static void AddTags(IDictionary <string, string> tags)
        {
            var mapOfTags = PusheAndroidUtils.CreateJavaMapFromDictionary(tags);

            PusheAndroidUtils.Native().CallStatic("addTags", mapOfTags);
        }
Beispiel #9
0
 private static AndroidJavaObject PiamService()
 {
     return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "inappmessaging"));
 }
Beispiel #10
0
 /// Set user's consent
 public static void SetUserConsentGiven()
 {
     PusheAndroidUtils.Native().CallStatic("setUserConsentGiven");
 }
Beispiel #11
0
        public static void SetNotificationListener(IPusheNotificationListener listener)
        {
            var callback = new NotificationCallback(listener);

            PusheAndroidUtils.PusheNotificationService().Call("setNotificationListener", callback);
        }
Beispiel #12
0
 public static string GetSubscribedTags()
 {
     return(PusheAndroidUtils.Extension().CallStatic <string>("getSubscribedTagsJson"));
 }
Beispiel #13
0
        public static void RemoveTags(params string[] tags)
        {
            var tagsToRemove = PusheAndroidUtils.CreateJavaArrayList(tags);

            PusheAndroidUtils.Native().CallStatic("removeTags", tagsToRemove);
        }
Beispiel #14
0
 /// <summary>
 /// Simply pass a void no argument function to this to handle initialization.
 ///
 /// * NOTE: This is not like Pushe.initialize() from Pushe 1.x. This is different.
 /// </summary>
 /// <param name="initCallback"></param>
 public static void OnPusheInitialized(PusheUnity.PusheDelegate initCallback)
 {
     PusheAndroidUtils.Native().CallStatic("setInitializationCompleteListener", new RegisterCallback(initCallback));
 }
Beispiel #15
0
 /// <summary>
 /// Get device advertising id (Google: Google Ad id, Huawei: Huawei OAID)
 /// </summary>
 /// <returns>Null if this feature was disabled by user and true otherwise</returns>
 public static string GetAdvertisingId()
 {
     return(PusheAndroidUtils.Native().CallStatic <string>("getAdvertisingId"));
 }
Beispiel #16
0
 /**
  * Simply pass a void no argument function to this function to handle registration
  */
 public static void OnPusheRegistered(PusheUnity.PusheDelegate pusheCallback)
 {
     PusheAndroidUtils.Native().CallStatic("setRegistrationCompleteListener", new RegisterCallback(pusheCallback));
 }
Beispiel #17
0
 /// <summary>
 /// Returns true if all pushe modules (Core, notification, etc.) were initialized.
 /// </summary>
 public static bool IsInitialized()
 {
     return(PusheAndroidUtils.Native().CallStatic <bool>("isInitialized"));
 }
Beispiel #18
0
 /// <summary>
 /// Check if pushe is registered to FCM
 /// </summary>
 public static bool IsRegistered()
 {
     return(PusheAndroidUtils.Native().CallStatic <bool>("isRegistered"));
 }
Beispiel #19
0
 public static bool IsForceForegroundAware()
 {
     return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isForegroundAwareByForce"));
 }
Beispiel #20
0
 public static void DisableCustomSound()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableCustomSound");
 }
Beispiel #21
0
 /// <summary>
 /// Returns unique id of device
 /// Following ID makes a unique ID that:
 /// - (Android 8.0 or higher): Is unique in an app and will be different on another app.
 /// - (Android lower that 8.0): Is a unique ID for all apps and each device will have only one id.
 /// </summary>
 public static string GetDeviceId()
 {
     return(PusheAndroidUtils.Native().CallStatic <string>("getDeviceId"));
 }
Beispiel #22
0
 /// <summary>
 /// GDPR related.
 /// If the user consent was given about necessary data collection for Pushe,
 ///     use this function to let pushe registration begin.
 /// To be able to use GDPR, add "pushe_requires_user_consent" meta-data value to "true",
 /// After showing the dialog and getting user's consent, call this onAccept.
 /// NOTE: Calling this only once is enough.
 /// </summary>
 public static void Initialize()
 {
     PusheAndroidUtils.Native().CallStatic("initialize");
 }
Beispiel #23
0
        public void onCustomContentNotification(AndroidJavaObject customContent)
        {
            var data = PusheAndroidUtils.Extension("notification").CallStatic <string>("mapToString", customContent);

            _listener.OnCustomContentReceived(data);
        }
Beispiel #24
0
 public static void SubscribeTo(string topic)
 {
     PusheAndroidUtils.Native().CallStatic("subscribeToTopic", topic, null);
 }
Beispiel #25
0
 public static void DisableNotification()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableNotifications");
 }
Beispiel #26
0
 /// <summary>
 ///  Send an event to the server. You can pass push notifications according to happening on some events.
 /// </summary>
 /// <param name="eventName">A name chosen by you</param>
 /// <b>If You don't have and action, leave it be custom.</b>
 public static void SendEvent(string eventName)
 {
     PusheAndroidUtils.PusheAnalyticsService().Call("sendEvent", eventName);
 }
Beispiel #27
0
 public static bool IsCustomSoundEnabled()
 {
     return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isCustomSoundEnable"));
 }
Beispiel #28
0
 public static void SendEcommerceData(string name, double price, string category = null, long quantity = -1)
 {
     PusheAndroidUtils.Extension("analytics").CallStatic("sendEcommerce", name, price, category, quantity);
 }
Beispiel #29
0
        /// <summary>
        /// With this function you can send notification from user to user.
        /// </summary>
        /// <exception cref="Exception">Will be thrown if needed param was entered as a null value</exception>
        public static void SendNotificationToUser(UserNotification userNotification)
        {
            if (userNotification.Id == null || userNotification.Title == null || userNotification.Content == null)
            {
                throw new Exception("id, title and content must be set.");
            }

            var userNotifClass = new AndroidJavaClass("co.pushe.plus.notification.UserNotification");
            AndroidJavaObject userNotif;

            switch (userNotification.Type)
            {
            case UserNotification.IdType.CustomId:
                userNotif = userNotifClass.CallStatic <AndroidJavaObject>("withCustomId", userNotification.Id);
                break;

            case UserNotification.IdType.AndroidId:
                userNotif = userNotifClass.CallStatic <AndroidJavaObject>("WithAndroidId", userNotification.Id);
                break;

            case UserNotification.IdType.GoogleAdId:
                userNotif = userNotifClass.CallStatic <AndroidJavaObject>("withAdvertisementId",
                                                                          userNotification.Id);
                break;

            default:
                throw new Exception("IdType is not valid");
            }

            userNotif = userNotif.Call <AndroidJavaObject>("setTitle", userNotification.Title)
                        .Call <AndroidJavaObject>("setContent", userNotification.Content);
            if (userNotification.IconUrl != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setIconUrl", userNotification.IconUrl);
            }

            if (userNotification.BigTitle != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setBigTitle", userNotification.BigTitle);
            }

            if (userNotification.BigContent != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setBigContent", userNotification.BigContent);
            }

            if (userNotification.ImageUrl != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setImageUrl", userNotification.ImageUrl);
            }

            if (userNotification.CustomContent != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setCustomContent", userNotification.CustomContent);
            }

            if (userNotification.AdvancedJson != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setAdvancedNotification", userNotification.AdvancedJson);
            }

            if (userNotification.NotifIcon != null)
            {
                userNotif = userNotif.Call <AndroidJavaObject>("setNotifIcon", userNotification.NotifIcon);
            }

            try
            {
                PusheAndroidUtils.PusheNotificationService().Call("sendNotificationToUser", userNotif);
            }
            catch (Exception e)
            {
                PusheUnity.Log("Could not send a notification " + e);
            }
        }
Beispiel #30
0
 public static string GetUserPhoneNumber()
 {
     return(PusheAndroidUtils.Native().CallStatic <string>("getUserPhoneNumber"));
 }