API Reference

extensionVersion

The extensionVersion API returns the library version.
Android
iOS

Java

Syntax
1
public static String extensionVersion();
Copied!
Example
1
Messaging.extensionVersion();
Copied!

Swift

Syntax
1
public static let extensionVersion
Copied!
Example
1
Messaging.extensionVersion
Copied!

Objective-C

Syntax
1
public static let extensionVersion
Copied!
Example
1
[AEPMobileMessaging extensionVersion];
Copied!

handleNotificationResponse

The handleNotificationResponse function transmits the push notification interaction feedback.
Android
iOS

Java

Syntax
1
public static void handleNotificationResponse(final Intent intent, final boolean applicationOpened, final String customActionId);
Copied!
Variable
Type
Description
intent
Intent
The intent contains information related to the messageId and the data.
applicationOpened
Boolean
Shows whether the application has been opened or not.
actionId
String
The ID of the custom action.
Example
1
// Intent can be retrieved from the Activity/BroadcastReceiver using the getIntent() method.
2
Intent intent = getIntent();
3
Messaging.handleNotificationResponse(intent, true, "customActionId");
Copied!

Swift

Syntax
1
static func handleNotificationResponse(_ response: UNNotificationResponse, applicationOpened: Bool, customActionId: String?)
Copied!
Variable
Type
Description
response
UNNotificationResponse
An object containing information about the push notification details.
applicationOpened
Boolean
Shows whether the application has been opened or not.
customActionId
String
The ID of the custom action.
Example
1
func userNotificationCenter(_: UNUserNotificationCenter,
2
didReceive response: UNNotificationResponse,
3
withCompletionHandler completionHandler: @escaping () -> Void) {
4
Messaging.handleNotificationResponse(response, applicationOpened: true, customActionId: "customActionId")
5
completionHandler()
6
}
Copied!

Objective-C

Syntax
1
@objc(handleNotificationResponse:applicationOpened:withCustomActionId:)
2
static func handleNotificationResponse(_ response: UNNotificationResponse, applicationOpened: Bool, customActionId: String?)
Copied!
Example
1
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
2
didReceiveNotificationResponse:(UNNotificationResponse *)response
3
withCompletionHandler:(void (^)())completionHandler {
4
// Your code
5
[AEPMobileMessaging handleNotificationResponse:response applicationOpened:true withCustomActionId:@"customActionId"]
6
completionHandler();
7
}
Copied!

registerExtension

The registerExtension API lets you register your extension with the Mobile Core.
Android
iOS

Java

Syntax
1
public static void registerExtension();
Copied!
Example
1
Messaging.registerExtension();
Copied!

Swift

You can use the MobileCore API to register the Messaging extension.
Syntax
1
public static func registerExtensions(_ extensions: [NSObject.Type], _ completion: (() -> Void)? = nil)
Copied!
Example
1
MobileCore.registerExtensions([Messaging.self, ...], {
2
// processing after registration
3
})
Copied!

Objective-C

You can use the AEPMobileCore API to register the Messaging extension.
Syntax
1
public static func registerExtensions(_ extensions: [NSObject.Type], _ completion: (() -> Void)? = nil)
Copied!
Example
1
[AEPMobileCore registerExtensions:@[AEPMobileMessaging.class, ...] completion:^{
2
// processing after registration
3
}];
Copied!

setPushIdentifier

Although this API is provided in Mobile Core, the use of this API is required and leveraged by the Adobe Journey Optimizer extension to sync provided push tokens with Adobe Experience Platform services.
The setPushIdentifier API sets the push token, allowing you to sync it with Profile in Adobe Experience Platform.
Android
iOS
To retrieve the push token from Firebase Messaging Service, please follow the tutorial within the Firebase documentation.

Java

Syntax
1
public static void setPushIdentifier(final String pushIdentifier);
Copied!
Variable
Type
Description
pushIdentifier
String
The push token that is synced with Adobe Experience Platform.
Example
1
FirebaseMessaging.getInstance().getToken()
2
.addOnCompleteListener(new OnCompleteListener<String>() {
3
@Override
4
public void onComplete(@NonNull Task<String> task) {
5
if (task.isSuccessful()) {
6
String token = task.getResult();
7
MobileCore.setPushIdentifier(token);
8
}
9
}
10
});
Copied!
To retrieve the push token in iOS, please read the tutorial within Apple's documentation.

Swift

Syntax
1
public static func setPushIdentifier(_ deviceToken: Data?)
Copied!
Variable
Type
Description
deviceToken
Data
The push token that is synced with Adobe Experience Platform.
Example
1
func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
2
MobileCore.setPushIdentifier(deviceToken)
3
}
Copied!

Objective-C

Syntax
1
public static func setPushIdentifier(_ deviceToken: Data?)
Copied!
Variable
Type
Description
deviceToken
Data
The push token that is synced with Adobe Experience Platform.
Example
1
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
2
[AEPMobileCore setPushIdentifier:deviceToken];
3
}
Copied!

addPushTrackingDetails

The addPushTrackingDetails API is used to update a pending intent with important information, such as messageId and Customer Journey information.
Note: Calling this API is mandatory, so the pending intent can be used while tracking push notification interactions.
Android

Java

Syntax
1
public static boolean addPushTrackingDetails(final Intent intent, final String messageId, final Map<String, String> data)
Copied!
Variable
Type
Description
intent
Intent
The pending intent that needs to be updated so it can be used when the user interacts with the notification.
messageId
String
The message ID for the push notification.
data
Map<String, String>
The data of the remoteMessage.
This API returns a boolean, indicating whether the intent was updated with necessary information (messageId and Customer Journey data).
Example
1
boolean success = addPushTrackingDetails(intent, messageId, data)
Copied!

Public classes

MessagingPushPayload

MessagePushPayload is a helper class for extracting the data payload attributes from RemoteMessage, which are used while creating the push notification.
Android

Java

Syntax
1
public MessagingPushPayload(RemoteMessage message)
Copied!
Variable
Type
Description
message
RemoteMessage
A message that contains the necessary attributes for creating a push notification.
1
public MessagingPushPayload(Map<String, String> data)
Copied!
Variable
Type
Description
data
Map<String, String>
A data payload that contains the necessary attributes for creating a push notification.
Examples
1
// Using the remote message
2
@Override
3
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
4
MessagingPushPayload payload = new MessagingPushPayload(remoteMessage);
5
}
6
7
// Using the data map
8
@Override
9
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
10
MessagingPushPayload payload = new MessagingPushPayload(remoteMessage.getData());
11
}
Copied!

Public APIs

Public APIs are used to get attributes from the push payload, which are used while creating the push notification.
Android

Java

Syntax
1
// Returns the title from the remote message
2
public String getTitle()
3
4
// Returns the body from the remote message
5
public String getBody()
6
7
// Returns the sound from the remote message
8
// The sound string represents the filename of a sound resource bundled in the app.
9
public String getSound()
10
11
// Returns the notification badge count from the remote message
12
public int getBadgeCount()
13
14
// Returns the notification priority from the remote message.
15
// For more information, please read the Firebase documentation (https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notificationpriority)
16
public int getNotificationPriority()
17
18
// Returns the channel ID from the remote message.
19
public String getChannelId()
20
21
// Returns the icon string from the remote message.
22
// The icon string represents the drawable resource name in the app.
23
public String getIcon()
24
25
// Returns the image URL from the remote message.
26
public String getImageUrl()
27
28
// Returns the data map from the remote message.
29
public Map<String, String> getData()
30
31
// Returns an ActionType object which represents the type of action which needs to be performed on push notification interaction.
32
// More information about the ActionType enum definition can be found in the ActionType section below.
33
public ActionType getActionType()
34
35
// Returns the action URI as a string. The action URI is used to direct the push notification interaction.
36
public String getActionUri()
37
38
// Returns a list of ActionButtons. More information about the ActionButtons class definition can be found in the ActionButtons section below.
39
public List<ActionButton> getActionButtons()
Copied!
Internal classes and enums
ActionType
1
public enum ActionType {
2
DEEPLINK, WEBURL, DISMISS, NONE
3
}
Copied!
ActionButtons
1
// Constructor
2
public ActionButton(final String label, final String link, final String type)
3
4
// Public APIs
5
6
// Returns the label for the action button
7
public String getLabel()
8
9
// Returns the link for the action button
10
public String getLink()
11
12
// Returns the ActionType for the action button
13
public ActionType getType()
Copied!

Payload keys

iOS
Android
1
{
2
"aps":{
3
"alert":{
4
"title":"Hello from CJM",
5
"body":"Stay safe, wear mask"
6
},
7
"sound":"dingDong",
8
"badge":2,
9
"mutable-content":1,
10
"category":"iosCategory",
11
"thread-id":"myGroup",
12
"content-available":1
13
},
14
"a":"x",
15
"b":"y",
16
"adb_media":"www.imageUrl.com",
17
"adb_a_type":"DEEPLINK/WEBURL/DISMISS",
18
"adb_uri":"deeplink://url / weburl",
19
"adb_act":[
20
{
21
"aid":"customId1",
22
"label":"dismiss",
23
"type":"DISMISS"
24
}
25
]
26
}
Copied!
Key
Type
Description
adb_media
String
The URL of the media. In this situation, media refers to either an image or a video. This URL can be used to download the rich media before showing the push notification.
adb_uri
String
The URI used for deeplinking. The deeplink is used to open appropriate webpage or app screen when the notification is clicked.
adb_a_type
enum
An enum that determines what type of action will be performed when the notification is selected. It can be one of the following string values: DEEPLINK, WEBURL, DISMISS.
adb_act
Array
An array that contains the action object(s).
adb_act.aid
String
The ID for the action object.
adb_act.label
String
The name for the action object
adb_act.type
String
The type for the action object. It can be one of the following string values: DEEPLINK, WEBURL, DISMISS
You should use the MessagingPushPayload class to extract the payload values.
1
{
2
"message":{
3
"android":{
4
"collapse_key": "new_message",
5
"priority": "HIGH",
6
"data":{
7
"adb_title":"Game Request",
8
"adb_body":"Bob wants to play chess",
9
"adb_sound" : "somesound_res",
10
"adb_n_count" : "3",
11
"." : "PRIORITY_LOW",
12
"adb_channel_id": "cid",
13
"adb_icon" : "notification_icon",
14
"adb_image": "www.imageUrl.com",
15
"adb_a_type": "DEEPLINK/WEBURL/DISMISS",
16
"adb_uri" : "uri/weburl",
17
"adb_act": [
18
{
19
"label" : "deeplink",
20
"uri" : "notificationapp://",
21
"type" : "DEEPLINK"
22
},
23
{
24
"label" : "weburl",
25
"uri" : "https://www.yahoo.com",
26
"type" : "WEBURL"
27
},
28
{
29
"label" : "dismiss",
30
"uri" : "",
31
"type" : "DISMISS"
32
}
33
],
34
"some_custom_data_key": "some data"
35
}
36
}
37
}
38
}
Copied!
Key
Type
Description
adb_title
String
The push notification's title
adb_body
String
The push notification's body
adb_sound
String
The push notification's sound
adb_n_count
String
The push notification badge count
adb_n_priority
String
The push notification's priority. For more information, please read the Firebase documentation
adb_channel_id
String
The push notification's channel ID
adb_icon
String
The push notification's icon resource name
adb_image
String
The URL of the image to be displayed on the notification
adb_a_type
enum
An enum that determines what type of action will be performed when the notification is clicked. It can be one of the following values: DEEPLINK, WEBURL, or DISMISS.
adb_uri
String
The URI used for deeplinking. The deeplink is used to open the appropriate webpage or app screen when the notification is clicked.
adb_act
Array
An array that contains the action object(s).
adb_act.label
String
The label for the action object
adb_act.uri
String
The URI for the action object
adb_act.type
enum
The action type for the action object. It can be one of the following values: DEEPLINK, WEBURL, DISMISS
Last modified 1mo ago