UTNotifications  1.5
Professional Local & Push Notification Plugin
Public Member Functions | Protected Member Functions | Properties | Events | List of all members
UTNotifications.Manager Class Referenceabstract

The main class providing UTNotifications API. More...

Inheritance diagram for UTNotifications.Manager:

Public Member Functions

abstract bool Initialize (bool willHandleReceivedNotifications, int startId=0, bool incrementalId=false)
 Initialize the Manager. Can be called more than once. More...
 
abstract void PostLocalNotification (string title, string text, int id, IDictionary< string, string > userData=null, string notificationProfile=null)
 Posts the local notification at once. More...
 
abstract void ScheduleNotification (int triggerInSeconds, string title, string text, int id, IDictionary< string, string > userData=null, string notificationProfile=null)
 Schedules the local notification. More...
 
void ScheduleNotification (DateTime triggerDateTime, string title, string text, int id, IDictionary< string, string > userData=null, string notificationProfile=null)
 Schedules the local notification. More...
 
abstract void ScheduleNotificationRepeating (int firstTriggerInSeconds, int intervalSeconds, string title, string text, int id, IDictionary< string, string > userData=null, string notificationProfile=null)
 Schedules the notification repeating. More...
 
void ScheduleNotificationRepeating (DateTime firstTriggerDateTime, int intervalSeconds, string title, string text, int id, IDictionary< string, string > userData=null, string notificationProfile=null)
 Schedules the notification repeating. More...
 
abstract bool NotificationsEnabled ()
 Checks if the notifications are enabled. More...
 
abstract void SetNotificationsEnabled (bool enabled)
 Enables or disables the notifications. More...
 
abstract void CancelNotification (int id)
 Cancels the notification with the specified id (ignored if the specified notification is not found). More...
 
abstract void HideNotification (int id)
 Hides the notification with the specified id (ignored if the specified notification is not found). More...
 
abstract void CancelAllNotifications ()
 Cancels all the notifications.

See also
CancelNotification
More...
 
abstract void HideAllNotifications ()
 Hides all the notifications.

See also
HideNotification
More...
 
abstract int GetBadge ()
 Returns the app icon badge value (iOS only). More...
 
abstract void SetBadge (int bandgeNumber)
 Sets the app icon badge value (iOS only). More...
 
delegate void OnSendRegistrationIdHandler (string providerName, string registrationId)
 
delegate void OnNotificationClickedHandler (ReceivedNotification notification)
 
delegate void OnNotificationsReceivedHandler (IList< ReceivedNotification > receivedNotifications)
 

Protected Member Functions

bool OnSendRegistrationIdHasSubscribers ()
 
void _OnSendRegistrationId (string providerName, string registrationId)
 
bool OnNotificationClickedHasSubscribers ()
 
void _OnNotificationClicked (ReceivedNotification notification)
 
bool OnNotificationsReceivedHasSubscribers ()
 
void _OnNotificationsReceived (IList< ReceivedNotification > receivedNotifications)
 
virtual void OnDestroy ()
 
void NotSupported (string feature=null)
 

Properties

static Manager Instance [get]
 This is how you access the only instance of the Manager. More...
 

Events

OnSendRegistrationIdHandler OnSendRegistrationId
 Occurs when the registrationId for push notifications is received and should be sent to your server. More...
 
OnNotificationClickedHandler OnNotificationClicked
 Occurs when user tapped/clicked on a notification. More...
 
OnNotificationsReceivedHandler OnNotificationsReceived
 Occurs when one or more local, scheduled or push notifications are received. More...
 

Detailed Description

The main class providing UTNotifications API.

It's a singleton which automatically creates a single GameObject "UTNotificationsManager" which is not destroyed on a scene loading.

Usage:

  1. If you would like to use not only local/scheduled notifications but also push notifications please subscribe to OnSendRegistrationId event.
    See also
    Manager.OnSendRegistrationId
  2. Call UTNotifications.Manager.Instance.Initialize in order to initialize the notifications system.
    See also
    Manager.Initialize
  3. Now you can start using all the UTNotifications.Manager API methods (see the methods description for further information)

Member Function Documentation

abstract void UTNotifications.Manager.CancelAllNotifications ( )
pure virtual

Cancels all the notifications.

See also
CancelNotification

abstract void UTNotifications.Manager.CancelNotification ( int  id)
pure virtual

Cancels the notification with the specified id (ignored if the specified notification is not found).

If the specified notification is scheduled or repeating all the future shows will be also canceled.

abstract int UTNotifications.Manager.GetBadge ( )
pure virtual

Returns the app icon badge value (iOS only).

Will always return 0 on non-iOS platforms.

abstract void UTNotifications.Manager.HideAllNotifications ( )
pure virtual

Hides all the notifications.

See also
HideNotification

Not supported and will be ignored on Windows Store.

abstract void UTNotifications.Manager.HideNotification ( int  id)
pure virtual

Hides the notification with the specified id (ignored if the specified notification is not found).

If the specified notification is scheduled or repeating all the future shows will remain scheduled. Not supported and will be ignored on Windows Store.

abstract bool UTNotifications.Manager.Initialize ( bool  willHandleReceivedNotifications,
int  startId = 0,
bool  incrementalId = false 
)
pure virtual

Initialize the Manager. Can be called more than once.

Parameters
willHandleReceivedNotificationsSet to true to be able to handle received notifications.
See also
OnNotificationsReceived
startIdID of a first received push notification
incrementalIdIf set to true each received push notfication will have an ID = previous push notification ID + 1. Otherwise all received push notifications will have ID = startId
Returns
true, if initialized successfully, false otherwise.

Please set willHandleReceivedNotifications to true only if you will handle received notifications using OnNotificationsReceived. Otherwise, all the received notifications will be stored and never cleaned. If incrementalId is false (default value), then new push notifications will replace old ones on Android so only one push notification can be shown at a time.

abstract bool UTNotifications.Manager.NotificationsEnabled ( )
pure virtual

Checks if the notifications are enabled.

abstract void UTNotifications.Manager.PostLocalNotification ( string  title,
string  text,
int  id,
IDictionary< string, string >  userData = null,
string  notificationProfile = null 
)
pure virtual

Posts the local notification at once.

Parameters
titleThe notification title.
textThe notification text.
idThe notification ID (any notifications with the same id will be replaced by this one).
See also
CancelNotification, HideNotification
userData(Optional) A custom IDictionary<string, string> that can be received in OnNotificationsReceived.
See also
OnNotificationsReceived
notificationProfile(Optional) The name of the notification profile (sound & icons settings).
abstract void UTNotifications.Manager.ScheduleNotification ( int  triggerInSeconds,
string  title,
string  text,
int  id,
IDictionary< string, string >  userData = null,
string  notificationProfile = null 
)
pure virtual

Schedules the local notification.

Parameters
triggerInSecondsSeconds value from now when the notification will be shown.
titleThe notification title.
textThe notification text.
idThe notification ID (any notifications with the same id will be replaced by this one).
See also
CancelNotification, HideNotification
userData(Optional) A custom IDictionary<string, string> that can be received in OnNotificationsReceived.
See also
OnNotificationsReceived
notificationProfile(Optional) The name of the notification profile (sound & icons settings).
void UTNotifications.Manager.ScheduleNotification ( DateTime  triggerDateTime,
string  title,
string  text,
int  id,
IDictionary< string, string >  userData = null,
string  notificationProfile = null 
)

Schedules the local notification.

Parameters
triggerDateTimeDateTime value when the notification will be shown.
titleThe notification title.
textThe notification text.
idThe notification ID (any notifications with the same id will be replaced by this one).
See also
CancelNotification, HideNotification
userData(Optional) A custom IDictionary<string, string> that can be received in OnNotificationsReceived.
See also
OnNotificationsReceived
notificationProfile(Optional) The name of the notification profile (sound & icons settings).
abstract void UTNotifications.Manager.ScheduleNotificationRepeating ( int  firstTriggerInSeconds,
int  intervalSeconds,
string  title,
string  text,
int  id,
IDictionary< string, string >  userData = null,
string  notificationProfile = null 
)
pure virtual

Schedules the notification repeating.

Parameters
firstTriggerInSecondsSeconds value from now when the notification will be shown first time.
intervalSecondsSeconds between the notification shows (see remarks).
titleThe notification title.
textThe notification text.
idThe notification ID (any notifications with the same id will be replaced by this one).
See also
CancelNotification, HideNotification
userData(Optional) A custom IDictionary<string, string> that can be received in OnNotificationsReceived.
See also
OnNotificationsReceived
notificationProfile(Optional) The name of the notification profile (sound & icons settings).

Please note that the actual interval may be different. On iOS there are only fixed options like every minute, every day, every week and so on. So the provided intervalSeconds value will be approximated by one of the available options.

void UTNotifications.Manager.ScheduleNotificationRepeating ( DateTime  firstTriggerDateTime,
int  intervalSeconds,
string  title,
string  text,
int  id,
IDictionary< string, string >  userData = null,
string  notificationProfile = null 
)

Schedules the notification repeating.

Parameters
firstTriggerDateTimeDateTime value when the notification will be shown first time.
intervalSecondsSeconds between the notification shows (see remarks).
titleThe notification title.
textThe notification text.
idThe notification ID (any notifications with the same id will be replaced by this one).
See also
CancelNotification, HideNotification
userData(Optional) A custom IDictionary<string, string> that can be received in OnNotificationsReceived.
See also
OnNotificationsReceived
notificationProfile(Optional) The name of the notification profile (sound & icons settings).

Please note that the actual interval may be different. On iOS there are only fixed options like every minute, every day, every week and so on. So the provided intervalSeconds value will be approximated by one of the available options.

abstract void UTNotifications.Manager.SetBadge ( int  bandgeNumber)
pure virtual

Sets the app icon badge value (iOS only).

Will be ignored on non-iOS platforms.

abstract void UTNotifications.Manager.SetNotificationsEnabled ( bool  enabled)
pure virtual

Enables or disables the notifications.

Please note that enabling may change the registrationId so OnSendRegistrationId event will be called.

See also
OnSendRegistrationId

Property Documentation

Manager UTNotifications.Manager.Instance
staticget

This is how you access the only instance of the Manager.

Event Documentation

OnNotificationClickedHandler UTNotifications.Manager.OnNotificationClicked

Occurs when user tapped/clicked on a notification.

Parameters
notificationClicked notification.
See also
UTNotifications.ReceivedNotification

To be able to handle a click on a notification which started an app, please subscribe on the event before calling Initialize.

OnNotificationsReceivedHandler UTNotifications.Manager.OnNotificationsReceived

Occurs when one or more local, scheduled or push notifications are received.

Parameters
receivedNotificationsA list of received ReceivedNotifications.
See also
UTNotifications.ReceivedNotification

iOS doesn't provide a list of all notifications shown when an app wasn't running in foreground. This list will contain only a notification, which was clicked and all notifications shown when an app is running in foreground. On other platforms, you'll receive a list of all shown notifications.

OnSendRegistrationIdHandler UTNotifications.Manager.OnSendRegistrationId

Occurs when the registrationId for push notifications is received and should be sent to your server.

Parameters
providerNameA name of a push notifications provider. May be "iOS", "GooglePlay" or "Amazon"
registrationIdThe received registrationId (encoded on iOS - see remarks)

Please note, that registrationId value on iOS is encoded value of APNS registration token (which is originally received as a binary buffer). The encoding can be Base64 (by default) or HEX based on the UTNotifications settings: Edit -> Project Settings -> UTNotifications -> iOS Settings -> APNS Registration Id encoding. On Android registrationId is not encoded.


The documentation for this class was generated from the following file: