Skip to main content
Version: 8.9.x

bfgLocalNotificationManager Class

Provides a straightforward interface for scheduling and cancelling local notifications. More...

Public Member Functions

void cancelNotification (final long notificationId)
 Cancel a pending or already-published notification. More...
 
long scheduleNotification (@Nullable final String title, @Nullable final String content, final int iconResourceId, @Nullable final Intent intent, final long epochTimeInMilliseconds, final boolean autoDismiss)
 Schedules a new notification with an SDK-assigned identifier. More...
 
long scheduleNotification (@Nullable final String title, @Nullable final String content, final int iconResourceId, final long replaceNotificationId, @Nullable final Intent intent, final long epochTimeInMilliseconds, final boolean autoDismiss)
 Schedules a new notification with an explicit identifier. More...
 

Detailed Description

Provides a straightforward interface for scheduling and cancelling local notifications. The class enables standardized management of local notifications that can survive a restart of the device.How local notifications work: Use scheduleNotification to request submission of a new notification at a specified time. The method may also be used to cancel a pending or published notification in favor of a newly-scheduled notification.Use cancelNotification to cancel submission of a pending notification or to remove an already-published notification.

Member Function Documentation

◆ cancelNotification()

void com.bigfishgames.bfglib.bfgLocalNotificationManager.cancelNotification (final long notificationId)
inline
Cancel a pending or already-published notification. Immediately cancel the notification identified by the argument. If the notification is pending (i.e., scheduled, but not yet published), then publication will be canceled. If the notification has already been published, then it will be removed from the notification tray.
Parameters
notificationIdA value of type long that uniquely identifies the notification. It may have been assigned in a prior call to scheduleNotification (value passed for replaceNotificationId) or returned by a prior call to scheduleNotification.

◆ scheduleNotification() [1/2]

long com.bigfishgames.bfglib.bfgLocalNotificationManager.scheduleNotification (@Nullable final String title,
@Nullable final String content,
final int iconResourceId,
@Nullable final Intent intent,
final long epochTimeInMilliseconds,
final boolean autoDismiss 
)
inline
Schedules a new notification with an SDK-assigned identifier. Schedule a notification for publication at a specific time. The arguments describe the appearance of the notification and an Android intent to be executed when the notification is tapped.
Parameters
titleA string value specifying the notification's title.
contentA string value specifying the text content of the notification.
iconResourceIdAn integer resource ID identifying the icon to use in the notification display. Note that this argument is required and that it must identify a valid "drawable" icon.
intentThis can be null or a valid instance of android.content.Intent. In the latter case, the Intent will be executed when the notification is tapped. Note that the Intent must be one that starts an Activity.
epochTimeInMillisecondsThis determines the time at which the notification will be published. It is specified as "epoch time"; i.e., UTC time in milliseconds since 00h00:00 January 1, 1970. For example, use (System.currentTimeMillis() + 300000) to schedule a notification for 5 minutes in the future.
autoDismissThis argument determines whether the notification will be removed from the notification tray automatically when the user taps the notification. Note that the argument will be ignored unless a non-null Intent is provided for the intent argument.
Returns
An integer value (Java type long) that uniquely identifies the scheduled notification. It may be used in cancelNotification or a subsequent call to scheduleNotification (replaceNotificationId argument) to cancel or replace the notification.

◆ scheduleNotification() [2/2]

long com.bigfishgames.bfglib.bfgLocalNotificationManager.scheduleNotification (@Nullable final String title,
@Nullable final String content,
final int iconResourceId,
final long replaceNotificationId,
@Nullable final Intent intent,
final long epochTimeInMilliseconds,
final boolean autoDismiss 
)
inline
Schedules a new notification with an explicit identifier. The method may also cancel a pending or already-published notification.Schedule a notification for publication at a specific time. The replaceNotificationId argument may be used to cancel a pending publication or to remove a notification that has already been published. The remaining arguments describe the appearance of the notification and an Android intent to be executed when the notification is tapped.
Parameters
titleA string value specifying the notification's title.
contentA string value specifying the text content of the notification.
iconResourceIdAn integer resource ID identifying the icon to use in the notification display. Note that this argument is required and that it must identify a valid "drawable" icon.
replaceNotificationIdAn integer identifier value assigned to the notification. If this ID is used in a subsequent call to scheduleNotification, then the prior notification will be canceled (if it is still pending) or removed from the notification tray (if it has already been published). Note that, when the method is called without a parameter value for replaceNotificationId, bfgLocalNotificationManager will automatically assign a negative integer identifier. Accordingly, developers may avoid clashes between user-assigned identifiers and SDK-assigned identifiers by using only non-negative integers for the former.
intentThis can be null or a valid instance of android.content.Intent. In the latter case, the Intent will be executed when the notification is tapped. Note that the Intent must be one that starts an Activity.
epochTimeInMillisecondsThis determines the time at which the notification will be published. It is specified as "epoch time"; i.e., UTC time in milliseconds since 00h00:00 January 1, 1970. For example, use (System.currentTimeMillis() + 300000) to schedule a notification for 5 minutes in the future.
autoDismissThis argument determines whether the notification will be removed from the notification tray automatically when the user taps the notification. Note that the argument will be ignored unless a non-null Intent is provided for the intent argument.
Returns
An integer value (Java type long) that uniquely identifies the scheduled notification. It may be used in cancelNotification or a subsequent call to scheduleNotification (replaceNotificationId argument) to cancel or replace the notification.