integrate the adobe mobile sdk with a mobile app to receive · pdf fileif you plan to€use...

16
Copyright © 2017, Adobe Adobe Campaign Page 1 1. 2. 3. 4. 5. 1. 2. 3. a. b. 4. 5. Integrate the Adobe Mobile SDK with a mobile app to receive ACS push notifications 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 (ACS). 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 ACS 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 Download the Adobe Mobile SDK and add the library to your mobile app project. For iOS: https://marketing.adobe.com/resources/help/en_US/mobile/ios/dev_qs.html For Android: https://marketing.adobe.com/resources/help/en_US/mobile/android/dev_qs.html Enable push messaging in your mobile app. For iOS: https://marketing.adobe.com/resources/help/en_US/mobile/ios/push_messaging.html For Android: https://marketing.adobe.com/resources/help/en_US/mobile/android/push_messaging.html Make sure you have access to an Adobe Campaign Standard (ACS) instance. Since the push notification feature is optional, check your license agreement so that you have it installed and enabled on the ACS instance. If you plan to use the to Location services feature of Adobe Mobile SDK send location-based push notifications to your mobile check that you h apps, ave access to Adobe Analytics-Mobile Apps or Analytics Premium, which is a specific SKU provided by Adobe Analytics. Steps to have ACS push notifications working on your mobile app Once you have fulfilled the prerequisites, go ahead with the following steps that will help get ACS push notification feature working on your mobile app. Enable the option as the for your mobile app. Remote notifications Background mode Create a mobile app on the ACS instance. Configure with the required postbacks. This can be done in two ways: ADBMobile JSON Config Manually editing the file ADBMobileConfig.json Using the Adobe Mobile Services UI Proceed to code changes in mobile app code to call the postbacks. Create a delivery in ACS to send a push notification. Document Purpose 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.

Upload: halien

Post on 30-Mar-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Copyright © 2017, Adobe

Adobe Campaign Page 1

1.

2.

3. 4.

5.

1. 2. 3.

a. b.

4. 5.

Integrate the Adobe Mobile SDK with a mobile app to receiveACS push notifications

Introduction

Adobe Campaign allows you to send personalized and segmented push notifications on iOS and Android mobile devices. In order toachieve this, you need to establish a relationship between your mobile application and Adobe Campaign, which is done by creating acorresponding configuration for your mobile app in Adobe Campaign Standard (ACS). The push messages are received on a mobileapplication and the appropriate data is captured from the application by leveraging the Adobe Marketing Cloud Mobile SDK. In thisdocument, we walk you through the steps involved in integrating these components while elaborating the detailed procedure forintegrating your mobile app with the Adobe Mobile SDK in order to receive ACS push notifications on the devices having your mobileapplication 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

Download the Adobe Mobile SDK and add the library to your mobile app project.For iOS:  https://marketing.adobe.com/resources/help/en_US/mobile/ios/dev_qs.htmlFor Android: https://marketing.adobe.com/resources/help/en_US/mobile/android/dev_qs.html

Enable push messaging in your mobile app.For iOS: https://marketing.adobe.com/resources/help/en_US/mobile/ios/push_messaging.htmlFor Android: https://marketing.adobe.com/resources/help/en_US/mobile/android/push_messaging.html

Make sure you have access to an Adobe Campaign Standard (ACS) instance.Since the push notification feature is optional, check your license agreement so that you have it installed and enabled on theACS instance.If you plan to use the   to   Location services feature of Adobe Mobile SDK send location-based push notifications to your mobile

check that you happs,  ave access to Adobe Analytics-Mobile Apps or Analytics Premium, which is a specific SKU provided byAdobe Analytics.

Steps to have ACS push notifications working on your mobile app

Once you have fulfilled the prerequisites, go ahead with the following steps that will help get ACS push notification feature working onyour mobile app.

Enable the   option as the  for your mobile app.Remote notifications Background mode Create a mobile app on the ACS instance.Configure  with the required postbacks. This can be done in two ways:ADBMobile JSON Config 

Manually editing the   fileADBMobileConfig.jsonUsing the Adobe Mobile Services UI

Proceed to code changes in mobile app code to call the postbacks.Create a delivery in ACS to send a push notification.

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

Copyright © 2017, Adobe

Adobe Campaign Page 2

1.

2.

1.

2.

1. 2. 3. 4.

1. 2.

1. 2. 3. 4.

5.

6.

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 Xcodeproject. (You can also enable this support by including the   key with the   valueUIBackgroundModes remote-notificationin your app’s   file.)Info.plistFor 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 ACS instance 

Before proceeding, you need to ensure that: 

You have access to the Mobile app channel in ACS. That would be the case if you have registered the license agreement forpush channel.You have obtained the below details that are required to facilitate push notifications to the end users who have installed yourapp.

For iOS:  .Obtain a push notification enabled provisioning profile for iOS (*.pem)Note: If your mobile app is a developer app, you will need to create a sandbox provisioning profile while if it is adistributed app, you will need a production provisioning profile.For Android:   or .Obtain a GCM API server key FCM API server key

 The mobile applications receiving push notifications must be configured by an administrator in the ACS interface. In case you areThe steps to create abuilding multiple mobile apps, you need to create a corresponding mobile app on ACS instance for each of them. 

mobile app on ACS instance are defined in the   section.Setting up a mobile application in Adobe Campaign

ADBMobile JSON Config Configure  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. Theconfigurations are eventually stored in the  JSON file. This section will walk you through the steps to achieve theADBMobileConfig same. The procedure is the same for both iOS and Android app, however the content may vary in the samples below.

, you need to:Before proceeding

Ensure that the   file is present in your project. This file is part of the AdobeMobileLibrary retrieved fromADBMobileConfig.jsonAdobe Mobile Services as part of the prerequisites.Gather the following information specific to your mobile app. You can find this information in the mobile application you created

  ):on your ACS instance (see Create a mobile app on the ACS instanceIMS Organization IDCollect PII EndpointCampaign Tracking Endpoint

- Location Services Endpoint  You must have access to Adobe Analytics-Mobile to view this endpoint URL.

 

Postbacks applicable for push notifications:

 

CollectPII - To collect personally identifiable information (PII) of mobile app subscribers.Registering - To register a mobile app subscriber to Adobe Campaign.Tracking - To track when a mobile app user clicked/opened a push notification.Location - To collect a user's location data that matches a Point of Interest.

There are two ways to configure the postbacks:

Using the Adobe Mobile Services user interface - You must have access to Adobe Analytics to use this method.Manually editing the ADBMobileConfig JSON file.

Using the Adobe Mobile Services user interface

Log into mobilemarketing.adobe.com.Click  from the left rail to list all applications.Manage Apps Select your application or click   to create a new one.AddScroll down to   check Visitor ID Service, Enable and select your organization from the drop-down list. Click Save.Note: This organization must be the same as the one you use on the Adobe Campaign instance.Click   from the toolbar.Manage Postbacks

Copyright © 2017, Adobe

Adobe Campaign Page 3

6.

7.

Create a postback:CollectPIISelect PII as the Postback Type.In the URL field, copy the Collect PII Endpoint URL that you gathered from your mobile application on the ACSinstance, preceded by your ACS server name.

The URL can only be "https". "http" is not allowed.Note: 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 bechanged/removed. The userKey field is optional, it simply enables you to reconcile your app subscribers with the

The user PII starts from the fourth line and can be customized as per requirement.recipients in the database. However, the keys should match the field IDs defined in your custom(for example cusEmail, cusFirstName) resource in the ACS instance. More details about custom resources, adding and extending them can be found inthe section. Adding or extending a resource The value variables (for example email, firstName) should match thekeys in the JSON data sent while .calling AMS collectPII API from app code

Set Content Type as application/json.Under  , select any trigger to define when the postback should be calledTrigger(s) . Typically, on launch or when theuser clicks a button. 

collectPII'For instance, in this document sample, we have used an identifier  'action' = '  to know when to trigger thepostback. So here, if  hisyou select the trigger as 'action' eq 'CollectPII', where action is a custom variable, then t

in order to satisfy the triggeridentifier will need to be sent in JSON data while   calling AMS collectPII API from app codecondition.Click Save & Activate.

Create a postback:RegisteringSelect Postback as the Postback Type.In the URL field, copy the   Collect PII Endpoint URL that you gathered from your mobile application on the ACSinstance, preceded by your ACS server name.

 "https" URL.Note: It is recommended to have anAdd Post Body and fill in your JSON payload.

Copyright © 2017, Adobe

Adobe Campaign Page 4

7.

8.

9.

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  , select ' ' as a Trigger of type  from the first dropdown and ' ' as matcher fromTrigger(s) Launched Event  existsthe second dropdown. This postback must be called on app launch and thus the trigger should be set as this only.Click Save & Activate.

Create a postback:TrackingSelect Postback as the Postback Type.In the URL field, copy the Campaign Tracking Endpoin  t URL that you gathered from your mobile application on ACSinstance, preceded by your ACS server name.

 "https" URL.Note: It is recommended to have anThe data for this postback call is sent in the form of URL parameters. You should be able to find the following threecontext variables in your   URL:Campaign Tracking Endpoint

broadlogIddeliveryIdaction

Note: The context variable names mentioned above should match the keys in the JSON data sent while calling AMS.trackAction API from app code

Under  , select any trigger to define when the postback should be calledTrigger(s) . Typically, this postback will be calledon an action.For example, in this document sample, we have used an identifier ' '. Action equals tracking This value will need to besent while   calling AMS trackAction API from app code in order to satisfy the trigger condition. Since using pushnotifications only tracks when the user clicks/opens a notification, triggers like on launch of an app etc. would not have ameaning here.Click Save & Activate.

Create a  postback:Location Select Postback as the Postback TypeIn the URL field, copy the Location Services Endpoint URL that you gathered from your mobile application on ACSinstance, preceded by your ACS server name.

 "https" URL.Note: It is recommended to have anAdd Post Body and fill in your JSON payload ( ).location context data

Sample JSON payload

Copyright © 2017, Adobe

Adobe Campaign Page 5

9.

10.

11.

1. 2.

3.

{       "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  , select any trigger to define when the postback should be called. Typically, on launch or when theTrigger(s)user clicks a button. For instance, in this document sample, we have used a trigger    to know when to trigger the'location.data' existspostback. So, this identifier will need to be sent in JSON data while   calling AMS trackLocation API from app code inorder to satisfy the trigger condition.Click  .Save & Activate

Note: Any location data sent using this postback will only get tracked if you have a Point of interest configured forthe same. (see  )Manage Points of Interest

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

Your app had the following 'remotes' object added to the  file before it was built into an APK.ADBMobileConfig.json 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.If you need to update your app code present in your IDE with the changes made in the Adobe Mobile Services UI, follow thesesteps:

Click   in the left rail.Manage App SettingsScroll all the way down to the  section.App SDK Downloads Click   to download the  file.Config File ADBMobileConfig.json Update the  file in your app project with this downloaded file.ADBMobileConfig.json 

Manually editing the ADBMobileConfig JSON file

Open the  file in your mobile app project.ADBMobileConfig.json Verify that the file contains the required settings for push messaging. The   object must have its   property configured for push messaging. The value of   should"marketingCloud" "org" "org"match the value of IMS Organization ID that you gathered from your mobile application on ACS instance.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":

Copyright © 2017, Adobe

Adobe Campaign Page 6

3.

"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",

Copyright © 2017, Adobe

Adobe Campaign Page 7

3.

"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"] }

Copyright © 2017, Adobe

Adobe Campaign Page 8

3.

4.

5.

1.

] } ]

Configure the CollectPII Postback:

Search for the message having messageId as "primaryCollectPII".Replace the value of  withtemplateurl   the  URL that you gathered from your mobile application onCollect PII Endpoint the ACS instance, preceded by the server name.

The URL can only be "https". "http" is not allowed.Note: Replace the  with your JSON payload, encoded to Base64. Information on how to encode thevalue of templatebody 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 The changed/removed. userKey field is optional, it simply enables you to reconcile your app subscribers with the

The user PII starts from the fourth line and can be customized as per requirement.recipients in the database. However, the keys should match the field IDs defined in your custom(for example cusEmail, cusFirstName) resource in ACS instance. More details about custom resources, adding and extending them can be found in the A

section. dding or extending a resource The value variables (for example email, firstName) should match the keys inthe JSON data sent while .calling AMS collectPII API from app code

You may adjust the value of  based on when triggers,  you would like the postback to be called. In this documentcollectPII'sample, we have used an  'action' = 'identifier    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

Configure the Registering Postback:

Search for the message having messageId as "registering".Replace the value of  withtemplateurl   the  URL that you gathered from your mobile application onCollect PII Endpoint the ACS instance, preceded by the server name.

 "https" URL.Note: It is recommended to have an Replace the  with your JSON payload, encoded to Base64. Information on how to encode thevalue of templatebody 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.

Configure   postback:TrackingSearch for the message having messageId as "tracking".Replace the value of  withtemplateurl   the  URL that you gathered from your mobileCampaign Tracking Endpoint application on the ACS instance, preceded by the server name.

"https" URL.Note: It is recommended to have an The data for this postback call is sent in the form of URL parameters. You should be able to find the following threecontext variables in your   URL:Campaign Tracking Endpoint

broadlogIddeliveryIdaction

Note: 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

Copyright © 2017, Adobe

Adobe Campaign Page 9

1.

2.

anything as long as the same value is sent while  , for the trigger condition tocalling AMS trackAction API from app codebe satisfied. Since using push notifications only tracks when the user clicks/opens a notification, triggers like on launchof an app etc. do not have a meaning here. 

Configure the   postback:LocationAdd the following object under messages array object in your  file.ADBMobileConfig.json 

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 isonly applicable for users who have access to Adobe Analytics - Mobile.

Copyright © 2017, Adobe

Adobe Campaign Page 10

2.

1.

Replace the value of  withtemplateurl   the  URL that you gathered from your mobileLocation Services Endpoint application on the ACS instance, preceded by the server name.

"https" URL.Note: It is recommended to have an Replace the  with your JSON payload ( ), encoded to Base64. Informationvalue of templatebody  location context dataon 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  based on when triggers,  you would like the postback to be called. In this documentsample, we have used a trigger  'location.data' exists to know when to trigger the postback. So, this identifier will needto 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 atthose locations, that will be reported. To know more visit  .Manage Points of Interest

To add points of interests manually, add a   object (similar to the one shown below) under the analytics objectpoipresent 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  file, you need to make some changes to yourADBMobileConfig.json app code to call those postbacks by calling the appropriate APIs in Adobe Mobile Services.

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

Copyright © 2017, Adobe

Adobe Campaign Page 11

1.

2.

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  and .com.adobe.mobile.Config com.adobe.mobile.Visitor

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

Call API for the postback.   trackAction Tracking

Copyright © 2017, Adobe

Adobe Campaign Page 12

2.

To enable tracking on the users who clicked/opened push notifications for your app, you need to call the trackAction API ofAdobe 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 sothat 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 notificationsboth 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 inAppDelegate.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 GCM app

// In onMessageReceived event handler in the implementation ofGCMListenerService public void onMessageReceived(String from, Bundle data) { String delivery = data.getString("_dId"); String broadlog = data.getString("_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.

Copyright © 2017, Adobe

Adobe Campaign Page 13

2.

3.

Sample Code for Android FCM app

// In onMessageReceived event handler in the implementation ofFirebaseMessagingService 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 thetracking logs in your   as shown in the image below:push notification delivery

Call API for the   postback. trackLocation  LocationBased on when you want to track the location of your mobile app user, under your event handler call the trackLocation APIexposed 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 APIFor iOS: Getting the User’s LocationFor Android: Android Location Strategies

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

Copyright © 2017, Adobe

Adobe Campaign Page 14

3.

Sample Code for iOS

- (void)locationManager:(CLLocationManager *)managerdidUpdateLocations:(NSArray *)locations { // Called when a new location is found. CLLocation* location = [locations lastObject]; NSMutableDictionary *contextData = [NSMutableDictionarydictionary]; [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 = newHashMap<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 ACS UI under the Adobe Campaign >Profiles & audiences > Profiles. This requires you to successfully reconcile the PII data with an existing profile on your ACSinstance and then you will see the location data under that particular profile.

Create a delivery in ACS to send a push notification

One you have configured both Adobe Campaign and Adobe Mobile Services  , you will beby leveraging the Marketing Cloud Mobile SDKable to use your mobile application's data for your campaigns. Adobe Campaign allows you to send personalized and segmented push

Copyright © 2017, Adobe

Adobe Campaign Page 15

1. 2. 3.

notifications on iOS and Android mobile devices.

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

Creating a deliveryDefining contentSending the push notification

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

Encoding JSON Payload to Base64

The value of any  in  file should be encoded to Base64 format as templatebody   ADBMobileConfig.json it is decoded andtoken-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. 

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

Copyright © 2017, Adobe

Adobe Campaign Page 16