This document intends to walk you through the procedure to integrate your mobile application with the Adobe Marketing Cloud Mobile SDK so that your mobile application is able to interact with Adobe Campaign. This integration will enable you to send personalized and segmented push notifications to mobile devices. You will also be able to use your mobile application's data for your campaigns. However, this document expects you to be familiar with the Abode Mobile SDK and thus does not dive into the details of the SDK and its capabilities.

Introduction

Adobe Campaign allows you to send personalized and segmented push notifications on iOS and Android mobile devices. In order to achieve this, you need to establish a relationship between your mobile application and Adobe Campaign, which is done by creating a corresponding configuration for your mobile app in Adobe Campaign Standard. The push messages are received on a mobile application and the appropriate data is captured from the application by leveraging the Adobe Marketing Cloud Mobile SDK.

In this document, we walk you through the steps involved in integrating these components while elaborating the detailed procedure for integrating your mobile app with the Adobe Mobile SDK in order to receive Adobe Campaign Standard push notifications on the devices having your mobile application installed.

The Adobe Mobile SDK enables the mobile application to:

  • Register the subscribers to Adobe Campaign.
  • Collect and send data to Adobe Campaign.
  • Track the notification clicks in Adobe Campaign.

Target audience

An iOS or Android mobile app developer with knowledge of the Adobe Mobile SDK and how push notifications work.

Prerequisites

  1. Download the Adobe Mobile SDK and add the library to your mobile app project.

  2. Make sure you have access to an Adobe Campaign Standard instance

  3. Since the push notification feature is optional, check your license agreement so that you have it installed and enabled on the Adobe Campaign Standard instance.

  4. If you plan to use the Location services feature of Adobe Mobile SDK to send location-based push notifications to your mobile apps, check that you have access to Adobe Analytics-Mobile Apps or Analytics Premium, which is a specific SKU provided by Adobe Analytics.

Steps to have Adobe Campaign Standard push notifications working on your mobile app

Once you have fulfilled the prerequisites, go ahead with the following steps that will help get Adobe Campaign Standard push notification feature working on your mobile app.

  1. Enable the Remote notifications option as the Background mode for your mobile app.

  2. Create a mobile app on the Adobe Campaign Standard instance.

  3. Configure ADBMobile JSON Config with the required postbacks. This can be done in two ways:

    • Manually editing the ADBMobileConfig.json file
    • Using the Adobe Mobile Services UI
  4. Proceed to code changes in mobile app code to call the postbacks.

  5. Create a delivery in Adobe Campaign Standard to send a push notification.

Enable Remote notifications as the Background mode

You will need to continue to run the app in the background in order to support click-through reporting.

To support this background mode:

  • For iOS: Enable the Remote notifications option from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the remote-notification value in your app’s Info.plist file.)
  • For Android: This would already be covered if you have followed the prerequisites of this document (see https://marketing.adobe.com/resources/help/en_US/mobile/android/push_messaging.html).

Create a mobile app on the Adobe Campaign Standard instance

Before proceeding, you need to ensure that:

  1. You have access to the Mobile app channel in Adobe Campaign Standard. That would be the case if you have registered the license agreement for push channel.

  2. You have obtained the below details that are required to facilitate push notifications to the end users who have installed your app.

    The mobile applications receiving push notifications must be configured by an administrator in the Adobe Campaign Standard interface. In case you are building multiple mobile apps, you need to create a corresponding mobile app on Adobe Campaign Standard instance for each of them. The steps to create a mobile app on Adobe Campaign Standard instance are defined in the Setting up a mobile application in Adobe Campaign section.

Configure ADBMobile JSON Config with the required postbacks

To send the data collected by the Adobe Mobile SDK to Adobe Campaign, you must configure postbacks in Adobe Mobile Services. The configurations are eventually stored in the ADBMobileConfig JSON file. This section will walk you through the steps to achieve the same. The procedure is the same for both iOS and Android app, however the content may vary in the samples below.

Before proceeding, you need to:

  1. Ensure that the ADBMobileConfig.json file is present in your project. This file is part of the AdobeMobileLibrary retrieved from Adobe Mobile Services as part of the prerequisites.

  2. Gather the following information specific to your mobile app. You can find this information in the mobile application you created on your Adobe Campaign Standard instance (see Create a mobile app on the Adobe Campaign Standard instance):

    • IMS Organization ID
    • Collect PII Endpoint
    • Campaign Tracking Endpoint
    • Location Services Endpoint - You must have access to Adobe Analytics-Mobile to view this endpoint URL.

Postbacks applicable for push notifications:

  1. CollectPII - To collect personally identifiable information (PII) of mobile app subscribers

  2. Registering - To register a mobile app subscriber to Adobe Campaign.

  3. Tracking - To track when a mobile app user clicked/opened a push notification.

  4. Location - To collect a user's location data that matches a Point of Interest.

There are two ways to configure the postbacks:

  1. Using the Adobe Mobile Services user interface - You must have access to Adobe Analytics to use this method.

  2. Manually editing the ADBMobileConfig JSON file.

Using the Adobe Mobile Services user interface

  1. Click Manage Apps from the left rail to list all applications.

  2.  

    Select your application or click Add to create a new one.

     

  3. Scroll down to Visitor ID Service, check Enable and select your organization from the drop-down list. Click Save.
    Note that this organization must be the same as the one you use on the Adobe Campaign instance.

  4. Click Manage Postbacks from the toolbar.

  5. Create a CollectPII postback:

    • Select PII as the Postback Type.
    • In the URL field, copy the Collect PII Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by your Adobe Campaign Standard server name.
      Note that the URL can only be "https": "http" is not allowed.
    • Add Post Body and fill in your JSON payload.
    Sample JSON Payload for iOS Sample JSON Payload for Android
    {
    "pushPlatform":"apns",
    "marketingCloudId":"{%mcid%}",
    "userKey": "{userKey}",
    "cusEmail":"{email}",
    "cusFirstName":"{firstName}",
    "cusLastName":"{lastName}"
    }
    {
    "pushPlatform":"gcm",
    "marketingCloudId":"{%mcid%}",
    "userKey": "{userKey}",
    "cusEmail":"{email}",
    "cusFirstName":"{firstName}",
    "cusLastName":"{lastName}"
    }

    Note:

    The first two key/value pairs (pushPlatform, marketingCloudId) are required and should not be changed/removed. The userKey field is optional, it simply enables you to reconcile your app subscribers with the recipients in the database. The user PII starts from the fourth line and can be customized as per requirement. However, the keys (for example cusEmail, cusFirstName) should match the field IDs defined in your custom resource in the Adobe Campaign Standard instance. More details about custom resources, adding and extending them can be found in the Adding or extending a resource section. The value variables (for example email, firstName) should match the keys in the JSON data sent while calling AMS collectPII API from app code.

    • Set Content Type as application/json.
    • Under Trigger(s), select any trigger to define when the postback should be called. Typically, on launch or when the user clicks a button. 
      For instance, in this document sample, we have used an identifier → 'action' = 'collectPII' to know when to trigger the postback. So here, if you select the trigger as 'actioneq 'CollectPII', where action is a custom variable, then this identifier will need to be sent in JSON data while calling AMS collectPII API from app code in order to satisfy the trigger condition.
    • Click Save & Activate.
    CollectPIIPostback
  6. Create a Registering postback:

    • Select Postback as the Postback Type.
    • In the URL field, copy the Collect PII Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by your Adobe Campaign Standard server name.
      Note: It is recommended to have an "https" URL.
    • Add Post Body and fill in your JSON payload.
    Sample JSON Payload for iOS Sample JSON Payload for Android
    {
    "pushPlatform":"apns",
    "marketingCloudId":"{%mcid%}"
    }
    {
    "pushPlatform":"gcm",
    "marketingCloudId":"{%mcid%}"
    }
    • Set Content Type as application/json.
    • Under Trigger(s), select 'Launched' as a Trigger of type Event from the first dropdown and 'exists' as matcher from the second dropdown. This postback must be called on app launch and thus the trigger should be set as this only.
    • Click Save & Activate.
  7. Create a Tracking postback:

    • Select Postback as the Postback Type.
    • In the URL field, copy the Campaign Tracking Endpoint URL that you gathered from your mobile application on Adobe Campaign Standard instance, preceded by your Adobe Campaign Standard server name.
      Note that it is recommended to have an "https" URL.

    • The data for this postback call is sent in the form of URL parameters. You should be able to find the following three context variables in your Campaign Tracking Endpoint URL:

      • broadlogId
      • deliveryId
      • action
      Note that the context variable names mentioned above should match the keys in the JSON data sent while calling AMS trackAction API from app code.
    • Under Trigger(s), select any trigger to define when the postback should be called. Typically, this postback will be called on an action.
      For example, in this document sample, we have used an identifier 'Action equals tracking'. This value will need to be sent while calling AMS trackAction API from app code in order to satisfy the trigger condition. Since using push notifications only tracks when the user clicks/opens a notification, triggers like on launch of an app etc. would not have a meaning here.
    • Click Save & Activate.
    TrackingPostback
  8. Create a Location postback:

    • Select Postback as the Postback Type

    • In the URL field, copy the Location Services Endpoint URL that you gathered from your mobile application on Adobe Campaign Standard instance, preceded by your Adobe Campaign Standard server name.
      Note that it is recommended to have an "https" URL.
    • Add Post Body and fill in your JSON payload (location context data).

    Sample JSON payload
    {
    "locationData":{
    "distances":"{a.loc.dist}",
    "poiLabel":"{a.loc.poi}",
    "latitude.a":"{a.loc.lat.a}",
    "latitude.b":"{a.loc.lat.b}",
    "latitude.c":"{a.loc.lat.c}",
    "longitude.a":"{a.loc.lon.a}",
    "longitude.b":"{a.loc.lon.b}",
    "longitude.c":"{a.loc.lon.c}",
    "appId":"{a.appid}",
    "marketingCloudId":"{mid}"
    }
    }
    • Set Content Type as application/json.

    • Under Trigger(s), select any trigger to define when the postback should be called. Typically, on launch or when the user clicks a button. 
      For instance, in this document sample, we have used a trigger → 'location.data' exists to know when to trigger the postback. So, this identifier will need to be sent in JSON data while calling AMS trackLocation API from app code in order to satisfy the trigger condition.

    • Click Save & Activate.

      Note that any location data sent using this postback will only get tracked if you have a Point of interest configured for the same. (see Manage Points of Interest)

  9. Any changes made in the Adobe Mobile Services UI will automatically be reflected in the corresponding mobile app installed on your device, provided that:

    • Your app had the following 'remotes' object added to the ADBMobileConfig.json file before it was built into an APK. This is a recommended step before building the app.

    "remotes": {
        "analytics.poi": "https://assets.adobedtm.com/b213090c5204bf94318f4ef0539a38b487d10368/scripts/satellite-59c2fd2f64746d36b7005f73.json",
        "messages": "https://assets.adobedtm.com/b213090c5204bf94318f4ef0539a38b487d10368/scripts/satellite-59c2fd2e64746d520200d606.json"
      }

    • You kill the app completely on your device and reopen it.

  10. If you need to update your app code present in your IDE with the changes made in the Adobe Mobile Services UI, follow these steps:

    • Click Manage App Settings in the left rail.

    • Scroll all the way down to the App SDK Downloads section.

    • Click Config File to download the ADBMobileConfig.json file.

    • Update the ADBMobileConfig.json file in your app project with this downloaded file.

Manually editing the ADBMobileConfig JSON file

  1. Open the ADBMobileConfig.json file in your mobile app project.

  2. Verify that the file contains the required settings for push messaging. 
    The "marketingCloud" object must have its "org" property configured for push messaging. The value of "org" should match the value of IMS Organization ID that you gathered from your mobile application on Adobe Campaign Standard instance.

  3. Add the following "messages" object to the JSON file. This object contains a message object for each of the postbacks.

    ADBMobileConfig.json

     "messages": [

                     {

                     "messageId": "primaryCollectPII",

                     "payload":

                        {

                        "templateurl": "https://<server_address>/rest/head/mobileApp/@e_kjEHsmINUomX-ABPLtbxmvV

                                    7EpQukUXVB5OPIvWk5hoNdieyYsM2aws9htjuhauOHOLhF7LoflRXh4CPyCQ0f0dBl8Ul2Yvi1PK6BZR_L

                                    eKuo0hBbnRR536axGseNcooVHrBAihxoG8OA5R8Q77rzWDl8/subscriptions/{%mcid%}",

                        "templatebody": "ew0KInVzZXJLZXkiOiAie3VzZXJLZXl9IiwNCiJwdXNoUGxhdGZvcm0iOiJhcG5zIiwNCiJtYXJrZ

                                    XRpbmdDbG91ZElkIjoieyVtY2lkJX0iLA0KImN1c0VtYWlsIjoie2VtYWlsfSIsDQoiY3VzRmlyc3ROYW1l

                                    Ijoie2ZpcnN0TmFtZX0iLA0KImN1c0xhc3ROYW1lIjoie2xhc3ROYW1lfSINCn0=",

                        "contenttype": "application/json",

                        "timeout": 2

                        },

                     "showOffline": true,

                     "showRule": "always",

                     "endDate": 2524730400,

                     "startDate": 0,

                     "template": "pii",

                     "audiences": [],

                     "triggers": [

                                    {

                                        "key": "action",

                                        "matches": "eq",

                                        "values": ["collectPII"]

                                    }

                                ]

                     },

     

                     {

                     "messageId": "registering",

                     "recipient": "Custom",

                     "payload":

                        {

                        "templateurl": "https://<server_address>/rest/head/mobileApp/@e_kjEHsmINUomX-ABPLtbxmvV

                                    7EpQukUXVB5OPIvWk5hoNdieyYsM2aws9htjuhauOHOLhF7LoflRXh4CPyCQ0f0dBl8Ul2Yvi1PK6BZR_L

                                    eKuo0hBbnRR536axGseNcooVHrBAihxoG8OA5R8Q77rzWDl8/subscriptions/{%mcid%}",

                        "templatebody": "ew0KInB1c2hQbGF0Zm9ybSI6ImFwbnMiLA0KIm1hcmtldGluZ0Nsb3VkSWQiOiJ7JW1jaWQlfSINCn0=",

                        "contenttype": "application/json",

                        "timeout": 2

                        },

                     "showOffline": true,

                     "showRule": "always",

                     "endDate": 2524730400,

                     "startDate": 0,

                     "template": "callback",

                     "audiences": [],

                     "triggers": [

                                    {

                                        "key": "a.LaunchEvent",

                                        "matches": "ex",

                                        "values": null

                                    }

                                 ]

                     },

     

                     {

                     "messageId": "tracking",

                     "recipient": "Custom",

                     "payload":

                        {

                        "templateurl": "https://<server_address>/r/?id={broadlogId},{deliveryId},{action}",

                        "templatebody": "",

                        "contenttype": "",

                        "timeout": 200

                        },

                     "showOffline": true,

                     "showRule": "always",

                     "endDate": 2524730400,

                     "startDate": 0,

                     "template": "callback",

                     "audiences": [],

                     "triggers": [

                                    {

                                        "key": "pev2",

                                        "matches": "eq",

                                        "values": ["AMACTION:tracking"]

                                    }

                                 ]

                     }

                ]

  4. Configure the CollectPII Postback:

    • Search for the message having messageId as "primaryCollectPII".
    • Replace the value of templateurl with the Collect PII Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by the server name.
      Note that the URL can only be "https": "http" is not allowed.
    • Replace the value of templatebody with your JSON payload, encoded to Base64. Information on how to encode the value to Base64 can be found here.
    Sample JSON Payload for iOS
    Sample JSON Payload for Android
    {
    "pushPlatform":"apns",
    "marketingCloudId":"{%mcid%}",
    "userKey": "{userKey}",
    "cusEmail":"{email}",
    "cusFirstName":"{firstName}",
    "cusLastName":"{lastName}"
    }
    {
    "pushPlatform":"gcm",
    "marketingCloudId":"{%mcid%}",
    "userKey": "{userKey}",
    "cusEmail":"{email}",
    "cusFirstName":"{firstName}",
    "cusLastName":"{lastName}"
    }

    Note:

    The first two key/value pairs (pushPlatform, marketingCloudId) are required and should not be changed/removed. The userKey field is optional, it simply enables you to reconcile your app subscribers with the recipients in the database. The user PII starts from the fourth line and can be customized as per requirement. However, the keys (for example cusEmail, cusFirstName) should match the field IDs defined in your custom resource in Adobe Campaign Standard instance. More details about custom resources, adding and extending them can be found in the Adding or extending a resource section. The value variables (for example email, firstName) should match the keys in the JSON data sent while calling AMS collectPII API from app code.

     

    • You may adjust the value of triggers, based on when you would like the postback to be called. In this document sample, we have used an identifier → 'action' = 'collectPII' to know when to trigger the postback. This identifier will need to be sent in JSON data while calling AMS collectPII API from app code.
  5. Configure the Registering Postback:

    • Search for the message having messageId as "registering".
    • Replace the value of templateurl with the Collect PII Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by the server name.
      Note that it is recommended to have an "https" URL.
      Replace the value of templatebody with your JSON payload, encoded to Base64. Information on how to encode the value to Base64 can be found here

    Sample JSON Payload for iOS
    Sample JSON Payload for Android
    {
    "pushPlatform":"apns",
    "marketingCloudId":"{%mcid%}"
    }
    {
    "pushPlatform":"gcm",
    "marketingCloudId":"{%mcid%}"
    }
    • This postback must be called on app launch and thus the trigger should be left as it is shown in the sample.
  6. Configure Tracking postback:

    • Search for the message having messageId as "tracking".
    • Replace the value of templateurl with the Campaign Tracking Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by the server name.
      Note that it is recommended to have an "https" URL.
    • The data for this postback call is sent in the form of URL parameters. You should be able to find the following three context variables in your Campaign Tracking Endpoint URL:

      • broadlogId
      • deliveryId
      • action
      Note that the context variable names mentioned above should match the keys in the JSON data sent while calling AMS trackAction API from app code.
    • The trigger in the sample code is specifying an Adobe Mobile action having its value as 'tracking'. This value can be anything as long as the same value is sent while calling AMS trackAction API from app code, for the trigger condition to be satisfied. Since using push notifications only tracks when the user clicks/opens a notification, triggers like on launch of an app etc. do not have a meaning here. 
  7. Configure the Location postback:

    • Add the following object under messages array object in your ADBMobileConfig.json file.

    ADBMobileConfig.json

    {

          "messageId": "location",

          "payload": {

            "templateurl": "https://<server_address>/rest/head/mobileApp/@e_kjEHsmINUomX-ABPLtbxmvV

                            7EpQukUXVB5OPIvWk5hoNdieyYsM2aws9htjuhauOHOLhF7LoflRXh4CPyCQ0f0dBl8Ul2Y

                            vi1PK6BZR_LeKuo0hBbnRR536axGseNcooVHrBAihxoG8OA5R8Q77rzWDl8/locations/",

            "templatebody": "ewogICJsb2NhdGlvbkRhdGEiOnsKICAgICAiZGlzdGFuY2VzIjoie2EubG9jLmRpc3R9IiwKICA

                            gICAicG9pTGFiZWwiOiJ7YS5sb2MucG9pfSIsCiAgICAgImxhdGl0dWRlLmEiOiJ7YS5sb2MubGF

                            0LmF9IiwKICAgICAibGF0aXR1ZGUuYiI6InthLmxvYy5sYXQuYn0iLAogICAgICJsYXRpdHVkZS5j

                            Ijoie2EubG9jLmxhdC5jfSIsCiAgICAgImxvbmdpdHVkZS5hIjoie2EubG9jLmxvbi5hfSIsCiAgICAg

                            ImxvbmdpdHVkZS5iIjoie2EubG9jLmxvbi5ifSIsCiAgICAgImxvbmdpdHVkZS5jIjoie2EubG9jLmxvb

                            i5jfSIsCiAgICAgImFwcElkIjoie2EuYXBwaWR9IiwKICAgICAibWFya2V0aW5nQ2xvdWRJZCI6ICJ7bWlkfSIKICB9Cn0=",

            "contenttype": "application/json",

            "timeout": 2

          },

          "showOffline": true,

          "showRule": "always",

          "endDate": 2524730400,

          "startDate": 0,

          "template": "callback",

          "audiences": [],

          "triggers": [

            {

              "key": "location.data",

              "matches": "ex",

              "values": null

            }

          ]

    }

    Note:

    This snippet was not included in the sample code provided above for all postbacks because location postback is only applicable for users who have access to Adobe Analytics - Mobile.

    • Replace the value of templateurl with the Location Services Endpoint URL that you gathered from your mobile application on the Adobe Campaign Standard instance, preceded by the server name.
      Note that it is recommended to have an "https" URL.
    • Replace the value of templatebody with your JSON payload (location context data), encoded to Base64. Information on how to encode the value to Base64 can be found here.

    Sample JSON payload
      
       "locationData":{   
          "distances":"{a.loc.dist}",
          "poiLabel":"{a.loc.poi}",
          "latitude.a":"{a.loc.lat.a}",
          "latitude.b":"{a.loc.lat.b}",
          "latitude.c":"{a.loc.lat.c}",
          "longitude.a":"{a.loc.lon.a}",
          "longitude.b":"{a.loc.lon.b}",
          "longitude.c":"{a.loc.lon.c}",
          "appId":"{a.appid}",
          "marketingCloudId":"{mid}"
       }
    }
    • You may adjust the value of triggers, based on when you would like the postback to be called. In this document sample, we have used a trigger → 'location.data' exists to know when to trigger the postback. So, this identifier will need to be sent in JSON data while calling AMS trackLocation API from app code in order to satisfy the trigger condition.

    • Any location data sent using this postback will only get tracked if you have a Point of interest configured for the same. You can configure multiple locations that are of interest to you so if the postback is triggered from your mobile app at those locations, that will be reported. To know more visit Manage Points of Interest.

      To add points of interests manually, add a poi object (similar to the one shown below) under the analytics object present in your ADBMobileConfig.json file.

    ADBMobileConfig.json

    "poi":[

            [

                "Adobe Systems",    // Name

                37.33091,           // Latitude

                -121.89352,         // Longitude

                100                 // Radius

            ],

            [

                "Random",

                59,

                -121.2,

                100

            ]

        ]

Code changes in mobile app code to call the postbacks

Once you have followed the steps to configure postbacks into the ADBMobileConfig.json file, you need to make some changes to your app code to call those postbacks by calling the appropriate APIs in Adobe Mobile Services.

  1. Call collectPII API for the CollectPII postback.
    Based on when you want to trigger the postback, under your event handler call the collectPII exposed by Adobe Mobile Services. In the process, you need to send the PII values for the fields you configured in JSON data with the following code:

    Sample Code for iOS

    NSString *mid = [ADBMobile visitorMarketingCloudID];

    [ADBMobile collectPII:@{

        @"userKey":@"man",

        @"marketingCloudId":mid,

        @"action":@"collectPII",

        @"email":_email_textfield.text,

        @"firstName":_firstName_textfield.text,

        @"lastName":_lastName_textfield.text}

    ];

    Note:

    You need to import ADBMobile.h.

    Sample code for Android

    EditText emailTextField = (EditText) findViewById(R.id.emailTextField);

    EditText firstNameTextField = (EditText) findViewById(R.id.firstNameTextField);

    EditText lastNameTextField = (EditText) findViewById(R.id.lastNameTextField);

     

    String emailStr = emailTextField.getText().toString();

    String firstNameStr = firstNameTextField.getText().toString();

    String lastNameStr = lastNameTextField.getText().toString();

    String mid = Visitor.getMarketingCloudId();

     

    HashMap<String, Object> data = new HashMap<>();

    data.put("userKey", "man");

    data.put("marketingCloudId", mid);

    data.put("action", "collectPII");

    data.put("email", emailStr);

    data.put("firstName", firstNameStr);

    data.put("lastName", lastNameStr);

    Config.collectPII(data);

    Note:

    You need to import com.adobe.mobile.Config and com.adobe.mobile.Visitor.

    Once the CollectPII postback is called successfully and if the PII data matches a profile that already exists on the  Adobe Campaign Standard instance, the reconciliation is done. The profile information will appear with the subscriber information present in that mobile app's settings on the Adobe Campaign Standard Instance:

    AppSubscribers
  2. Call trackAction API for the Tracking postback.

    To enable tracking on the users who clicked/opened push notifications for your app, you need to call the trackAction API of Adobe Mobile Services from the event that is captured in your app code when a push notification is received and opened. Additionally, you need to send the data for the three context variables that are part of the tracking postback endpoint URL so that the tracking is categorized in the right bucket: 

    • broadlogId - received in the event handler from the push notifications payload.
    • deliveryId - received in the event handler from the push notifications payload.
    • action - the value can be "1" or "2". "1" implies opened while "2" implies clicked but since in case of push notifications both click and open refer to the same action, you would probably want to use one of the values.
    Sample Code for iOS

    // In didReceiveRemoteNotification event handler in AppDelegate.m

     

    - (void)application:(UIApplication *)application

    didReceiveRemoteNotification:(NSDictionary *)userInfo {  

     

        NSString *delivery = userInfo[@"_dId"];

        NSString *broadlog = userInfo[@"_mId"];

     

        if (application.applicationState != UIApplicationStateActive) {

            // only send the hit if the app is not active

            if(delivery != nil && broadlog != nil ){

                [ADBMobile trackAction:@"tracking" data:@{

                    @"deliveryId": delivery,

                    @"broadlogId": broadlog,

                    @"action":@"1"

                }];

            }

        }

    }

    Note:

    You need to import ADBMobile.

    Sample Code for Android FCM app

    // In onMessageReceived event handler in the implementation of FirebaseMessagingService

     

    public void onMessageReceived(RemoteMessage message) {

        Map<String, String> dataMap = message.getData();

        

        String delivery = dataMap.get("_dId");

        String broadlog = dataMap.get("_mId");

     

        HashMap<String, Object> contextData = new HashMap<String, Object>();

        if(delivery != null && broadlog != null ){

            contextData.put("deliveryId", delivery);

            contextData.put("broadlogId", broadlog);

            contextData.put("action", "1");

            Analytics.trackAction("tracking", contextData);

        }

    }

    Note:

    You need to import com.adobe.mobile.Analytics.

    Once you receive the push notification and the tracking postback is called successfully for that notification, you can view the tracking logs in your push notification delivery as shown in the image below:

    TrackingLogs
  3. Call trackLocation API for the Location postback.
    Based on when you want to track the location of your mobile app user, under your event handler call the trackLocation API exposed by Adobe Mobile Services. This API will need you to send:

    • Location Information - You can use the following links to determine the location that is passed to the API

    • Context Data - In addition to the location data, you can send additional context data with each track location call. For example, in the sample code we are sending "location.data" = "found" to satisfy the trigger condition for this postback.

    Sample Code for iOS

    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {

        // Called when a new location is found.

        CLLocation* location = [locations lastObject];

        NSMutableDictionary *contextData = [NSMutableDictionary dictionary];

        [contextData setObject:@"found" forKey:@"location.data"];

        [ADBMobile trackLocation: location data: contextData];

    }

    Note:

    You need to import ADBMobile.

    Sample code for Android

    public void onLocationChanged(Location location) {

        // Called when a new location is found.

        HashMap<String, Object> contextData = new HashMap<String, Object>();

        contextData.put("location.data", "found");

        Analytics.trackLocation(location, contextData);

    }

    Note:

    You need to import com.adobe.mobile.Analytics.

    Once the location data is sent to mobile services, you can view the location data in Adobe Campaign Standard UI under the Adobe Campaign > Profiles & audiences > Profiles.

    This requires you to successfully reconcile the PII data with an existing profile on your Adobe Campaign Standard instance and then you will see the location data under that particular profile.

    LocationData

Create a delivery in Adobe Campaign Standard to send a push notification

One you have configured both Adobe Campaign and Adobe Mobile Services by leveraging the Marketing Cloud Mobile SDK, you will be able to use your mobile application's data for your campaigns. Adobe Campaign allows you to send personalized and segmented push notifications on iOS and Android mobile devices.

The process of creating a push notification delivery includes the following primary steps:

  1. Creating a delivery
  2. Defining content
  3. Sending the push notification

The detailed instructions to achieve the same can be found in the Creating a push notification section.

 

Encoding JSON Payload to Base64

The value of any templatebody in ADBMobileConfig.json file should be encoded to Base64 format as it is decoded and token-expanded prior to being sent in the POST call, made to the postback URL.

You can do this by creating your template body in a text editor and then copying and pasting it into a Base64 encoder

image2017-10-4_16-2-38

From there, copy the encoded value and paste it as the value for templatebody.

image2017-10-4_16-3-19

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy