public final class NotificationsManager extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
NotificationsManager.NotificationExtender
Allows for customizing of notifications before they are displayed.
|
static interface |
NotificationsManager.PrepareCallback
Represents handlers to be invoked when preparation of a card is completed.
|
Modifier and Type | Field and Description |
---|---|
static String |
EXTRA_PAYLOAD_INTENT
The intent extra key to be used for pending intents used in notifications created by
`presentNotification()`
|
static String |
LIBRARY_VERSION
The version of the In-App Notifications Library
|
static String |
PAYLOAD_VERSION
The highest supported payload version by this version of the Notifications SDK
|
static int |
REQUEST_CODE
The request code to use for intents returned by
NotificationsManager.PrepareCallback |
Modifier and Type | Method and Description |
---|---|
static boolean |
canPresentCard(Bundle notificationBundle)
Returns whether or not a notification bundle has a valid push payload.
|
static NotificationCardResult |
handleActivityResult(int requestCode,
int resultCode,
Intent data)
Handle the result of an activity started using
prepare(Context, Bundle, PrepareCallback) or present(Activity, Bundle) . |
static void |
prepareCard(Context context,
Bundle notificationBundle,
NotificationsManager.PrepareCallback callback)
Prepare and pre-load a notification bundle into memory.
|
static boolean |
presentCard(Activity activity,
Bundle notificationBundle)
Present an intent from a given activity to show the notification bundle contained in notificationBundle.
|
static boolean |
presentCardFromNotification(Activity activity)
Present a card from the notification this activity
was created from, if the notification exists.
|
static boolean |
presentCardFromNotification(Activity activity,
Intent intent)
Present a card from the notification this activity
was relaunched from, if the notification exists.
|
static void |
presentNotification(Context context,
Bundle notificationBundle,
Intent launcherIntent)
Present a
Notification to be presented from a GCM push bundle. |
static void |
presentNotification(Context context,
Bundle notificationBundle,
Intent launcherIntent,
NotificationsManager.NotificationExtender notificationExtender)
Present a
Notification to be presented from a GCM push bundle. |
public static final int REQUEST_CODE
NotificationsManager.PrepareCallback
public static final String EXTRA_PAYLOAD_INTENT
public static final String PAYLOAD_VERSION
public static final String LIBRARY_VERSION
public static boolean canPresentCard(@NonNull Bundle notificationBundle)
notificationBundle
- The bundle to check for a push payloadpublic static boolean presentCard(@NonNull Activity activity, @NonNull Bundle notificationBundle)
activity
- The activity to present fromnotificationBundle
- The bundle containing the notification payload to presentpublic static void prepareCard(@NonNull Context context, @NonNull Bundle notificationBundle, @NonNull NotificationsManager.PrepareCallback callback)
context
- The current context of your program. Usually an activity, application, or
service context.notificationBundle
- The bundle containing the notification payload to presentcallback
- The callback to invoke once preparation is complete. This is guaranteed to be
invoked on the same thread as this method is invoked from.public static NotificationCardResult handleActivityResult(int requestCode, int resultCode, @Nullable Intent data)
prepare(Context, Bundle, PrepareCallback)
or present(Activity, Bundle)
.requestCode
- The request code used to start the activityresultCode
- The result code returned by the activitydata
- The data returned by the activitypublic static void presentNotification(@NonNull Context context, @NonNull Bundle notificationBundle, @NonNull Intent launcherIntent)
Notification
to be presented from a GCM push bundle.
This does not present a notification immediately, instead it caches the assets from the
notification bundle, and then presents a notification to the user. This allows for a smoother
interaction without loading indicators for the user.
Note that only one notification can be created for a specific push bundle, should you attempt
to present a new notification with the same payload bundle as an existing notification, it will
replace and update the old notification.context
- The context to send the notification fromnotificationBundle
- The content of the push notificationlauncherIntent
- The launcher intent that contains your Application's activity.
This will be modified with the FLAG_ACTIVITY_CLEAR_TOP and
FLAG_ACTIVITY_SINGLE_TOP flags, in order to properly show the
notification in an already running application.
Should you not want this behavior, you may use the notificationExtender
parameter to customize the contentIntent of the notification before
presenting it.public static void presentNotification(@NonNull Context context, @NonNull Bundle notificationBundle, @NonNull Intent launcherIntent, @Nullable NotificationsManager.NotificationExtender notificationExtender)
Notification
to be presented from a GCM push bundle.
This does not present a notification immediately, instead it caches the assets from the
notification bundle, and then presents a notification to the user. This allows for a smoother
interaction without loading indicators for the user.
Note that only one notification can be created for a specific push bundle, should you attempt
to present a new notification with the same payload bundle as an existing notification, it will
replace and update the old notification.context
- The context to send the notification fromnotificationBundle
- The content of the push notificationlauncherIntent
- The launcher intent that contains your Application's activity.
This will be modified with the FLAG_ACTIVITY_CLEAR_TOP and
FLAG_ACTIVITY_SINGLE_TOP flags, in order to properly show the
notification in an already running application.
Should you not want this behavior, you may use the notificationExtender
parameter to customize the contentIntent of the notification before
presenting it.notificationExtender
- A nullable argument that allows you to customize the notification
before displaying it. Use this to configure Icons, text, sounds,
etc. before we pass the notification off to the OS.public static boolean presentCardFromNotification(@NonNull Activity activity)
activity
- The activity to present from.public static boolean presentCardFromNotification(@NonNull Activity activity, @NonNull Intent intent)
activity
- The activity to present from.intent
- Intent that was used to re-launch the activity.