Package com.batch.android
Class BatchPushPayload
java.lang.Object
com.batch.android.BatchPushPayload
- All Implemented Interfaces:
PushUserActionSource
,UserActionSource
Convenience object to retrieve standardized Batch data out of a Batch Push intent.
This class does not have a public constructor. You must use
This class does not have a public constructor. You must use
payloadFromBundle(android.os.Bundle)
or payloadFromReceiverIntent(android.content.Intent)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents a payload parsing exception. -
Method Summary
Modifier and TypeMethodDescriptionGet the actions associated with this push, if any.getBigPictureURL
(Context context) Get the big picture url contained in this push.
You should always check if the push contains a big picture usinghasBigPicture()
.
The url returned by this method is already optimized for the device, you have to download the image and use it in the notificationGet the desired notification channel.getCustomLargeIconURL
(Context context) Get the custom large icon url contained in this push.
You should always check if the push contains a custom large icon usinghasCustomLargeIcon()
.
The url returned by this method is already optimized for the device, you have to download the image and use it in the notificationGet the deeplink url contained in this push.
You should always check if the push contains a deeplink usinghasDeeplink()
getGroup()
Get the notification group name.Returns the landing message that's in this payload if there is one.Get the raw push bundleboolean
Does this push contains a big pictureboolean
Does this push contains a custom large iconboolean
Does this push contains a deeplinkboolean
Whether the payload contains a landing message or notboolean
Get the notification group name.static BatchPushPayload
payloadFromBundle
(Bundle bundle) Attempt to extract the Batch Push data contained within the specified Bundle.
This is usually the method you want to use when reading this payload from an activity opened by Batch, or when you wrote an existing BatchPushPayload to a Bundle/Intent extras usingwriteToBundle(android.os.Bundle)
/writeToIntentExtras(android.content.Intent)
.static BatchPushPayload
payloadFromFirebaseMessage
(com.google.firebase.messaging.RemoteMessage remoteMessage) Attempt to extract the Batch Push data contained within the specified Firebase RemoteMessage.
This is usually the method you want to use when reading this payload from a FirebaseMessagingService implementation, NOT from an activity intent.static BatchPushPayload
payloadFromReceiverExtras
(Bundle extras) Attempt to extract the Batch Push data contained within the specified Intent extras.
This is usually the method you want to use when reading this payload from a push broadcast receiver/service, NOT from an activity intent.static BatchPushPayload
payloadFromReceiverIntent
(Intent intent) Attempt to extract the Batch Push data contained within the specified Intent.
This is usually the method you want to use when reading this payload from a push broadcast receiver/service, NOT from an activity intent.void
writeToBundle
(Bundle bundle) Serialize this instance into aBundle
.
Note that you'll need to usepayloadFromBundle(android.os.Bundle)
with the intent's extras to read it back.void
writeToIntentExtras
(Intent intent) Serialize this instance into anIntent
.
-
Method Details
-
payloadFromBundle
public static BatchPushPayload payloadFromBundle(Bundle bundle) throws BatchPushPayload.ParsingException Attempt to extract the Batch Push data contained within the specified Bundle.
This is usually the method you want to use when reading this payload from an activity opened by Batch, or when you wrote an existing BatchPushPayload to a Bundle/Intent extras usingwriteToBundle(android.os.Bundle)
/writeToIntentExtras(android.content.Intent)
.- Parameters:
bundle
- Bundle containing Batch Push data. Parsed data is read from the key defined byBatch.Push#PAYLOAD_KEY
.- Returns:
- A BatchPushPayload instance.
- Throws:
BatchPushPayload.ParsingException
- Thrown if the argument doesn't contain valid Batch Push data
-
payloadFromReceiverIntent
public static BatchPushPayload payloadFromReceiverIntent(Intent intent) throws BatchPushPayload.ParsingException Attempt to extract the Batch Push data contained within the specified Intent.
This is usually the method you want to use when reading this payload from a push broadcast receiver/service, NOT from an activity intent. If you wrote an existing BatchPushPayload to a Bundle/Intent extras usingwriteToBundle(android.os.Bundle)
/writeToIntentExtras(android.content.Intent)
, you should rather usepayloadFromBundle(android.os.Bundle)
- Parameters:
intent
- Broadcast receiver intent containing Batch Push data.- Returns:
- A BatchPushPayload instance.
- Throws:
BatchPushPayload.ParsingException
- Thrown if the argument doesn't contain valid Batch Push data
-
payloadFromReceiverExtras
public static BatchPushPayload payloadFromReceiverExtras(Bundle extras) throws BatchPushPayload.ParsingException Attempt to extract the Batch Push data contained within the specified Intent extras.
This is usually the method you want to use when reading this payload from a push broadcast receiver/service, NOT from an activity intent. If you wrote an existing BatchPushPayload to a Bundle/Intent extras usingwriteToBundle(android.os.Bundle)
/writeToIntentExtras(android.content.Intent)
, you should rather usepayloadFromBundle(android.os.Bundle)
- Parameters:
extras
- Broadcast receiver intent's extras containing Batch Push data.- Returns:
- A BatchPushPayload instance.
- Throws:
BatchPushPayload.ParsingException
- Thrown if the argument doesn't contain valid Batch Push data
-
payloadFromFirebaseMessage
public static BatchPushPayload payloadFromFirebaseMessage(com.google.firebase.messaging.RemoteMessage remoteMessage) throws BatchPushPayload.ParsingException Attempt to extract the Batch Push data contained within the specified Firebase RemoteMessage.
This is usually the method you want to use when reading this payload from a FirebaseMessagingService implementation, NOT from an activity intent. If you wrote an existing BatchPushPayload to a Bundle/Intent extras usingwriteToBundle(android.os.Bundle)
/writeToIntentExtras(android.content.Intent)
, you should rather usepayloadFromBundle(android.os.Bundle)
- Parameters:
remoteMessage
- Firebase remote message containing Batch Push data.- Returns:
- A BatchPushPayload instance.
- Throws:
BatchPushPayload.ParsingException
- Thrown if the argument doesn't contain valid Batch Push data
-
writeToBundle
Serialize this instance into aBundle
.
Note that you'll need to usepayloadFromBundle(android.os.Bundle)
with the intent's extras to read it back.- Parameters:
bundle
- Bundle instance to serialize this in
-
writeToIntentExtras
Serialize this instance into anIntent
. Note that you'll need to usepayloadFromBundle(android.os.Bundle)
with the intent's extras to read it back.
This method WILL NOT fill the intent in a format thatpayloadFromReceiverIntent(android.content.Intent)
understands.- Parameters:
intent
- Intent instance to serialize this in
-
hasDeeplink
public boolean hasDeeplink()Does this push contains a deeplink- Returns:
- true if this push contains a deeplink, false otherwise
-
getDeeplink
Get the deeplink url contained in this push.
You should always check if the push contains a deeplink usinghasDeeplink()
- Returns:
- the deeplink if any, null otherwise
-
hasCustomLargeIcon
public boolean hasCustomLargeIcon()Does this push contains a custom large icon- Returns:
- true if this push contains a custom large icon to download, false otherwise
-
getCustomLargeIconURL
Get the custom large icon url contained in this push.
You should always check if the push contains a custom large icon usinghasCustomLargeIcon()
.
The url returned by this method is already optimized for the device, you have to download the image and use it in the notification- Returns:
- the custom large icon url if any, null otherwise
-
hasBigPicture
public boolean hasBigPicture()Does this push contains a big picture- Returns:
- true if this push contains a big picture to download, false otherwise
-
getBigPictureURL
Get the big picture url contained in this push.
You should always check if the push contains a big picture usinghasBigPicture()
.
The url returned by this method is already optimized for the device, you have to download the image and use it in the notification- Returns:
- the big picture url if any, null otherwise
-
hasLandingMessage
public boolean hasLandingMessage()Whether the payload contains a landing message or not -
getLandingMessage
Returns the landing message that's in this payload if there is one.- Returns:
- the landing message, if there is one
-
getActions
Get the actions associated with this push, if any. -
getGroup
Get the notification group name. Meant to be used withNotificationCompat.Builder.setGroup(String)
- Returns:
- Group name string, null if none
-
isGroupSummary
public boolean isGroupSummary()Get the notification group name. Meant to be used withNotificationCompat.Builder.setGroupSummary(boolean)
- Returns:
- Whether this notification should be a group summary or not
-
getChannel
Get the desired notification channel. Meant to be used withNotificationCompat.Builder.setChannelId(String)
- Returns:
- The notification channel this push should be displayed on, if applicable. Can be null.
-
getPushBundle
Get the raw push bundle- Specified by:
getPushBundle
in interfacePushUserActionSource
-