using VoxelBusters.NativePlugins;
public class NotificationManager : MonoBehaviour
public static NotificationManager Instance { get { return _instance; } }
[Tooltip("Alert: Shows up alert / banner on receiving a notification. " +
"Badge: Shows a badge on receiving a notification, if set. " +
"Sound: Plays sound on receiving a notification. " +
"None: None of the above.")]
public NotificationType notificationProperties;
protected static NotificationManager _instance;
protected NotificationManager m_OldInstanceToDestroy = null;
if (Instance != null && Instance != this)
m_OldInstanceToDestroy = Instance;
if(Input.GetKeyDown(KeyCode.E))
Instance.AddLocalNotification(eNotificationRepeatInterval.NONE, false, "Help", "No", "Notification.mp3", 10);
NPBinding.NotificationService.RegisterNotificationTypes(notificationProperties);
public void AddLocalNotification(DateTime time, eNotificationRepeatInterval repeatingInterval, bool hasActionButton, string alertBodyText, string alertActionText, string soundName)
CrossPlatformNotification notification = CreateNotification(time, repeatingInterval, hasActionButton, alertBodyText, alertActionText, soundName);
NPBinding.NotificationService.ScheduleLocalNotification(notification);
public void AddLocalNotification(double daysTillFire, eNotificationRepeatInterval repeatingInterval, bool hasActionButton, string alertBodyText, string alertActionText, string soundName)
AddLocalNotification(DateTime.Now.AddDays(daysTillFire), repeatingInterval, hasActionButton, alertBodyText, alertActionText, soundName);
public void AddLocalNotification(eNotificationRepeatInterval repeatingInterval, bool hasActionButton, string alertBodyText, string alertActionText, string soundName, long secondsTillFire)
AddLocalNotification(DateTime.Now.AddSeconds(secondsTillFire), repeatingInterval, hasActionButton, alertBodyText, alertActionText, soundName);
public void CancelAllScheduledLocalNotifications()
NPBinding.NotificationService.CancelAllLocalNotification();
#region Private Functions
private CrossPlatformNotification CreateNotification(DateTime time, eNotificationRepeatInterval repeatingInterval, bool hasActionButton, string alertBodyText, string alertActionText, string soundName)
CrossPlatformNotification.iOSSpecificProperties iosProperties = new CrossPlatformNotification.iOSSpecificProperties();
iosProperties.HasAction = hasActionButton;
iosProperties.AlertAction = alertActionText;
CrossPlatformNotification notification = new CrossPlatformNotification();
notification.AlertBody = alertBodyText;
notification.FireDate = time;
notification.RepeatInterval = repeatingInterval;
notification.SoundName = soundName;
notification.iOSProperties = iosProperties;