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 :|"); } }
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); }
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); }
/// <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!"); } }
public static void DisableNotificationForceForegroundAware() { PusheAndroidUtils.PusheNotificationService().Call("disableNotificationForceForegroundAware"); }
public static AndroidJavaObject PusheAnalyticsService() { return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "analytics")); }
public static AndroidJavaObject PusheNotificationService() { return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "notification")); }
public static void AddTags(IDictionary <string, string> tags) { var mapOfTags = PusheAndroidUtils.CreateJavaMapFromDictionary(tags); PusheAndroidUtils.Native().CallStatic("addTags", mapOfTags); }
private static AndroidJavaObject PiamService() { return(PusheAndroidUtils.Native().CallStatic <AndroidJavaObject>("getPusheService", "inappmessaging")); }
/// Set user's consent public static void SetUserConsentGiven() { PusheAndroidUtils.Native().CallStatic("setUserConsentGiven"); }
public static void SetNotificationListener(IPusheNotificationListener listener) { var callback = new NotificationCallback(listener); PusheAndroidUtils.PusheNotificationService().Call("setNotificationListener", callback); }
public static string GetSubscribedTags() { return(PusheAndroidUtils.Extension().CallStatic <string>("getSubscribedTagsJson")); }
public static void RemoveTags(params string[] tags) { var tagsToRemove = PusheAndroidUtils.CreateJavaArrayList(tags); PusheAndroidUtils.Native().CallStatic("removeTags", tagsToRemove); }
/// <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)); }
/// <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")); }
/** * 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)); }
/// <summary> /// Returns true if all pushe modules (Core, notification, etc.) were initialized. /// </summary> public static bool IsInitialized() { return(PusheAndroidUtils.Native().CallStatic <bool>("isInitialized")); }
/// <summary> /// Check if pushe is registered to FCM /// </summary> public static bool IsRegistered() { return(PusheAndroidUtils.Native().CallStatic <bool>("isRegistered")); }
public static bool IsForceForegroundAware() { return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isForegroundAwareByForce")); }
public static void DisableCustomSound() { PusheAndroidUtils.PusheNotificationService().Call("disableCustomSound"); }
/// <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")); }
/// <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"); }
public void onCustomContentNotification(AndroidJavaObject customContent) { var data = PusheAndroidUtils.Extension("notification").CallStatic <string>("mapToString", customContent); _listener.OnCustomContentReceived(data); }
public static void SubscribeTo(string topic) { PusheAndroidUtils.Native().CallStatic("subscribeToTopic", topic, null); }
public static void DisableNotification() { PusheAndroidUtils.PusheNotificationService().Call("disableNotifications"); }
/// <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); }
public static bool IsCustomSoundEnabled() { return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isCustomSoundEnable")); }
public static void SendEcommerceData(string name, double price, string category = null, long quantity = -1) { PusheAndroidUtils.Extension("analytics").CallStatic("sendEcommerce", name, price, category, quantity); }
/// <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); } }
public static string GetUserPhoneNumber() { return(PusheAndroidUtils.Native().CallStatic <string>("getUserPhoneNumber")); }