Class Notifications
Inheritance
Namespace: EasyMobile
Assembly: cs.temp.dll.dll
Syntax
public class Notifications : MonoBehaviour
Properties
CurrentPushNotificationService
Gets the current push notification service.
Declaration
public static PushNotificationProvider CurrentPushNotificationService { get; }
Property Value
Type | Description |
---|---|
PushNotificationProvider | The current push notification service. |
DataPrivacyConsent
The module-level data privacy consent status, default to ConsentStatus.Unknown.
Declaration
public static ConsentStatus DataPrivacyConsent { get; }
Property Value
Type | Description |
---|---|
ConsentStatus |
Instance
Declaration
public static Notifications Instance { get; }
Property Value
Type | Description |
---|---|
Notifications |
PushToken
If a remote notification service is used, this contains the registration token for your app once it is received from the server. If no remote notification service was selected, or if it hasn't been initialized, this will be null.
Declaration
public static string PushToken { get; }
Property Value
Type | Description |
---|---|
System.String | The token. |
Methods
CancelAllPendingLocalNotifications()
Cancels all pending local notifications.
Declaration
public static void CancelAllPendingLocalNotifications()
CancelPendingLocalNotification(String)
Cancels the pending local notification with the specified ID.
Declaration
public static void CancelPendingLocalNotification(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | Identifier. |
ClearAllDeliveredNotifications()
Removes all previously shown notifications of this app from the notification center or status bar.
Declaration
public static void ClearAllDeliveredNotifications()
GetAppIconBadgeNumber()
Gets the app icon badge number. This methods is only effective on iOS. On other platforms it always returns 0.
Declaration
public static int GetAppIconBadgeNumber()
Returns
Type | Description |
---|---|
System.Int32 | The app icon badge number. |
GetPendingLocalNotifications(Action<NotificationRequest[]>)
Gets all scheduled local notifications that haven't been posted.
Declaration
public static void GetPendingLocalNotifications(Action<NotificationRequest[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<NotificationRequest[]> | callback | The callback that is invoked when this operation finishes. This callback receives an array of all pending notification requests. If there's no pending notifications, an empty array will be returned. This callback will always execute on the main thread (game thread)./> |
GrantDataPrivacyConsent()
Grants module-level data privacy consent. This consent persists across app launches.
Declaration
public static void GrantDataPrivacyConsent()
Remarks
This method is a wrapper of NotificationsConsentManager.Instance.GrantDataPrivacyConsent
.
Init()
Initializes local and remote notification services.
Declaration
public static void Init()
IsInitialized()
Determines if the module has been initialized.
Declaration
public static bool IsInitialized()
Returns
Type | Description |
---|---|
System.Boolean |
|
RevokeDataPrivacyConsent()
Revokes the module-level data privacy consent. This consent persists across app launches.
Declaration
public static void RevokeDataPrivacyConsent()
Remarks
This method is a wrapper of NotificationsConsentManager.Instance.RevokeDataPrivacyConsent
.
ScheduleLocalNotification(DateTime, NotificationContent)
Schedules a local notification to be posted at the specified time with no repeat. Note that the scheduled notification persists even if the device reboots, and it will be fired immediately after the reboot if the triggerDate has passed.
Declaration
public static string ScheduleLocalNotification(DateTime triggerDate, NotificationContent content)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | triggerDate | Trigger date. |
NotificationContent | content | Notification content. |
Returns
Type | Description |
---|---|
System.String | The ID of the scheduled notification. |
ScheduleLocalNotification(TimeSpan, NotificationContent)
Schedules a local notification to be posted after the specified delay time with no repeat. Note that the scheduled notification persists even if the device reboots, and it will be fired immediately after the reboot if the delay time has passed.
Declaration
public static string ScheduleLocalNotification(TimeSpan delay, NotificationContent content)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | delay | Delay. |
NotificationContent | content | Notification content. |
Returns
Type | Description |
---|---|
System.String | The ID of the scheduled notification. |
ScheduleLocalNotification(TimeSpan, NotificationContent, NotificationRepeat)
Schedules a local notification to be posted after the specified delay time, and repeat automatically after the interval specified by the repeat mode. Note that the scheduled notification persists even if the device reboots, and it will be fired immediately after the reboot if its latest scheduled fire time has passed.
Declaration
public static string ScheduleLocalNotification(TimeSpan delay, NotificationContent content, NotificationRepeat repeat)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | delay | Delay. |
NotificationContent | content | Notification content. |
NotificationRepeat | repeat | Repeat. |
Returns
Type | Description |
---|---|
System.String | The ID of the scheduled notification. |
SetAppIconBadgeNumber(Int32)
Sets the app icon badge number. This methods is only effective on iOS. On other platforms it is a no-op.
Declaration
public static void SetAppIconBadgeNumber(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Value. |
Events
DataPrivacyConsentUpdated
Raised when the module-level data privacy consent is changed.
Declaration
public static event Action<ConsentStatus> DataPrivacyConsentUpdated
Event Type
Type | Description |
---|---|
System.Action<ConsentStatus> |
LocalNotificationOpened
Occurs when a local notification is opened, either by the default open action, or by a custom notification action button. Note that if the notification arrives when the app is in foreground it won't be posted to the notification center. Instead, this event will be raised immediately as if the notification was opened by the user.
Declaration
public static event Action<LocalNotification> LocalNotificationOpened
Event Type
Type | Description |
---|---|
System.Action<LocalNotification> |
PushTokenReceived
Occurs when a token is received once the selected remote notification service has been initialized.
Declaration
public static event Action<string> PushTokenReceived
Event Type
Type | Description |
---|---|
System.Action<System.String> |
RemoteNotificationOpened
Occurs when a remote notification is opened, either by the default open action, or by a custom notification action button. Note that if the notification arrives when the app is in foreground it won't be posted to the notification center. Instead, this event will be raised immediately as if the notification was opened by the user.
Declaration
public static event Action<RemoteNotification> RemoteNotificationOpened
Event Type
Type | Description |
---|---|
System.Action<RemoteNotification> |