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 :|"); } }
/// <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!"); } }
/// <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 void SetNotificationListener(IPusheNotificationListener listener) { var callback = new NotificationCallback(listener); PusheAndroidUtils.PusheNotificationService().Call("setNotificationListener", callback); }
public static bool IsCustomSoundEnabled() { return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isCustomSoundEnable")); }
public static void DisableCustomSound() { PusheAndroidUtils.PusheNotificationService().Call("disableCustomSound"); }
public static void DisableNotification() { PusheAndroidUtils.PusheNotificationService().Call("disableNotifications"); }
public static bool IsForceForegroundAware() { return(PusheAndroidUtils.PusheNotificationService().Call <bool>("isForegroundAwareByForce")); }
public static void DisableNotificationForceForegroundAware() { PusheAndroidUtils.PusheNotificationService().Call("disableNotificationForceForegroundAware"); }