Ejemplo n.º 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 :|");
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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!");
     }
 }
Ejemplo n.º 5
0
 public static void DisableNotificationForceForegroundAware()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableNotificationForceForegroundAware");
 }
Ejemplo n.º 6
0
 public static AndroidJavaObject PusheAnalyticsService()
 {
     return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "analytics"));
 }
Ejemplo n.º 7
0
 public static AndroidJavaObject PusheNotificationService()
 {
     return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "notification"));
 }
Ejemplo n.º 8
0
        public static void AddTags(IDictionary <string, string> tags)
        {
            var mapOfTags = PusheAndroidUtils.CreateJavaMapFromDictionary(tags);

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

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

            PusheAndroidUtils.Native().CallStatic("removeTags", tagsToRemove);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Check if pushe is registered to FCM
 /// </summary>
 public static bool IsRegistered()
 {
     return(PusheAndroidUtils.Native().CallStatic <bool>("isRegistered"));
 }
Ejemplo n.º 19
0
 public static bool IsForceForegroundAware()
 {
     return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isForegroundAwareByForce"));
 }
Ejemplo n.º 20
0
 public static void DisableCustomSound()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableCustomSound");
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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");
 }
Ejemplo n.º 23
0
        public void onCustomContentNotification(AndroidJavaObject customContent)
        {
            var data = PusheAndroidUtils.Extension("notification").CallStatic <string>("mapToString", customContent);

            _listener.OnCustomContentReceived(data);
        }
Ejemplo n.º 24
0
 public static void SubscribeTo(string topic)
 {
     PusheAndroidUtils.Native().CallStatic("subscribeToTopic", topic, null);
 }
Ejemplo n.º 25
0
 public static void DisableNotification()
 {
     PusheAndroidUtils.PusheNotificationService().Call("disableNotifications");
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 27
0
 public static bool IsCustomSoundEnabled()
 {
     return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isCustomSoundEnable"));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 30
0
 public static string GetUserPhoneNumber()
 {
     return(PusheAndroidUtils.Native().CallStatic <string>("getUserPhoneNumber"));
 }