In this lesson, you will implement the Mobile SDK with the extensions and settings corresponding to your Launch property’s Development environment.
At the end of this lesson, you will be able to:
The Installation Instructions for mobile Launch properties are a collection of code snippets that you either run in your Terminal or add to specific locations in your mobile app.
Click on the Environments
tab in the top navigation to go to the environments page. Note that Development, Staging, and Production environments have been pre-created for you. These correspond to the typical environments in the code development and release process. Code is first written by a developer in a Development environment. When they have completed their work, they send it to a Staging environment for QA and other teams to review. Once the QA and other teams are satisfied, the code is then published to the Production environment, which is the public-facing environment which your visitors experience when they download your app.
Launch permits additional Development environments, which is useful in large organizations in which multiple developers are working on different projects at the same time.
Development, Staging, and Production are the only environments we need to complete the tutorial.
In the Development row, click the Install icon to open the embed code modal.
Let’s go through the instructions step-by-step.
If you have previously used Launch in websites, one of the first things you will notice is that there is a lot more information in this modal than for web properties.
The Adobe Mobile SDK for iOS uses the CocoaPods to manage dependencies between its various components. If you don’t already have CocoaPods installed in your development environment, follow the installation instructions on their website. Also, if you haven’t already downloaded the Bus Booking app, save it to your local machine and extract the zip archive to your desktop.
To create the Podfile
Open the Terminal
Application on your Mac®
Navigate to the project folder where you saved the Bus Booking Objective-C app (e.g. cd Desktop/busbooking-mobileapps-master/Objective-C/
)
In the Launch interface, change the operating system to iOS
Copy the first iOS instruction pod init
, by clicking the icon
In your Terminal app, run the pod init
command and wait for it to complete
In your Terminal app, open the podfile with the open podfile
command
Your computer may open a dialog asking with which application you would like to open the podfile. Choose any text editor, like TextEdit
In the Launch interface, copy the list of dependencies by clicking the icon. Note how there is a line corresponding to each one of the extensions you added in the earlier lesson. Each extension has its own set of code which builds on the Mobile Core extension and can only be added or removed with an app update:
In your text editor, paste the dependencies from your clipboard right after the line # Pods for BusBookingObjectiveC
Save the updates to the podfile in your text editor
You can now close your text editor
In the Launch interface, copy the next iOS instruction pod repo update
, by clicking the icon
In your Terminal app, run the pod repo update
command and wait for it to complete (this might take a few minutes)
In the Launch interface, copy the next iOS instruction pod install
, by clicking the icon
In your Terminal app, run the pod install
command and wait for it to complete
You can now close your Terminal window
Open a Finder window, navigate to the folder where you saved the Bus Booking app, and confirm that the BusBookingObjectiveC.xcworkspace file, the Podfile, the Podfile.lock file, as well as the Pods folder have been created
Now it’s time to update the App to import the SDK:
Open the BusBookingObjectiveC.xcworkspace
file in XCode
Open the AppDelegate.m
file
In the Launch interface, scroll to the Add Initialization Code section and choose Objective C as the iOS language you are using.
Copy the import statements, by clicking the first icon in the Add Initialization Code section:
In XCode, paste these import statements into the AppDelegate.m
file after the import for the AppDelegate.h
In the Launch interface, copy the two lines related to the Core extension, by clicking the second icon in the Add Initialization Code section. The first line turns on console logging statements (available options are). The second line points to the unique identifier of the Launch environment. This is important, as you will need to update this value when we are ready to deploy the app to the production environment.
In XCode, paste these Core statements into the AppDelegate file at the top of the application(_:didFinishLaunchingWithOptions:)
method:
In the Launch interface, copy the extension statements, by clicking the third icon in the Add Initialization Code section:
In XCode, paste these extension statements into the AppDelegate file just before the return true
line of the application(_:didFinishLaunchingWithOptions:)
method:
The Mobile Install Instructions provided in the Launch interface include the import and registration statements for Identity, Lifecycle, and Signal extensions, as well as the initialization of the Lifecyle metrics. These extensions are considered part of the Mobile Core extension. If you do not wish to use these extensions in your app, you do not need to import, register, or implement other code associated with these extensions.
Also, there are additional implementation options which should be considered when using these extensions (for example, you could pause/restart Lifecycle collection when the user backgrounds/foregrounds the app). You can read more about this in the Mobile Core extension documentation
Save your XCode project
Run the app and launch it in the Simulator. If you don’t have any simulator devices configured, configure one now, being sure to configure a device running iOS 10+. We like to use an iPhone 8 simulator because it is easy to click the Home
button with a mouse.
Wait for the Simulator to launch and fully open the app to the booking screen (this may take a few minutes)
Confirm that calls are being made to the Adobe servers in the XCode Console
Here are examples of some specific calls you can look for:
Calls to retrieve the Launch configuration (filter your console to adobedtm.com
). Note the extension configurations which you entered in the earlier lesson. While adding the extension requires an update to the app, these settings can be managed externally in Launch and changed at any time:
2019-03-13 16:53:26.633816-0400 BusBookingObjectiveC[56630:3854917] [AMSDK DEBUG <RulesDownloader>]: Successfully downloaded Rules from 'https://assets.adobedtm.com/launch-EN360aefc739b04410816f751a95861744-development-rules.zip'
{"target.propertyToken":"","target.timeout":5,"global.privacy":"optedin","analytics.backdatePreviousSessionInfo":true,"analytics.offlineEnabled":true,"build.environment":"dev","rules.url":"https://assets.adobedtm.com/launch-EN360aefc739b04410816f751a95861744-development-rules.zip","experienceCloud.org":"7ABB3E6A5A7491460A495D61@AdobeOrg","target.clientCode":"techmarketingdemos","target.autoFetch":true,"target.fetchBackground":false,"lifecycle.sessionTimeout":300,"target.environmentId":"busbookingapp","analytics.server":"tmd.sc.omtrdc.net","analytics.rsids":"tmd-mobile-dev1","analytics.batchLimit":0,"property.id":"PRb4881271498b4f2cbaf67d38a8f3891a","global.ssl":true,"analytics.aamForwardingEnabled":true}
Request to the Identity Service (filter your console to demdex.net
) In this example, the ID (d_mid
)has already been set and is just being reported up again)
2019-03-13 16:53:26.655908-0400 BusBookingObjectiveC[56630:3854937] [AMSDK DEBUG <com.adobe.module.identity>]:
Sending request (https://dpm.demdex.net/id?d_rtbd=json&d_ver=2&d_orgid=7ABB3E6A5A7491460A495D61@AdobeOrg&d_mid=67027929491180584128922600814231770586)
Response from the Identity Service (filter your console to ID Service
). Note how the mid
value matches the d_mid
value in the request above:
2019-03-13 16:53:27.397048-0400 BusBookingObjectiveC[56630:3854937] [AMSDK DEBUG <com.adobe.module.identity>]:
ID Service - Got ID Response (mid: 67027929491180584128922600814231770586, blob: j8Odv6LonN4r3an7LhD3WZrU1bUpAkFkkiY1ncBR96t2PTI, hint: 9, ttl: "604800000 ms")
Analytics request (filter your console to Analytics request
)
2019-03-13 16:53:27.689061-0400 BusBookingObjectiveC[56630:3855024] [AMSDK DEBUG <AnalyticsHitDatabase>]: Analytics request was sent with body
(ndh=1&c.&a.&AppID=BusBookingObjectiveC%201%20%281.0%29&CarrierName=%28null%29&DailyEngUserEvent=DailyEngUserEvent&DayOfWeek=4&DeviceName=x86_64&HourOfDay=16&InstallDate=3%2F13%2F2019&InstallEvent=InstallEvent&LaunchEvent=LaunchEvent&Launches=1&MonthlyEngUserEvent=MonthlyEngUserEvent&OSVersion=iOS%2012.1&Resolution=750x1334&RunMode=Application&TimeSinceLaunch=1&internalaction=Lifecycle&locale=en-US&.a&.c&ce=UTF-8&cp=foreground&mid=67027929491180584128922600814231770586&pageName=BusBookingObjectiveC%201%20%281.0%29&pe=lnk_o&pev2=ADBINTERNAL%3ALifecycle&t=00%2F00%2F0000%2000%3A00%3A00%200%20240&ts=1552510406)
Congratulations, you’ve added the SDK to a mobile app!
Next “Add the Adobe Experience Platform Identity Service” >