You can use supported Adobe Experience Platform mobile extensions in your App Extensions to collect usage data. The supported AEP mobile extensions are listed here.
- This tutorial assumes a basic understanding of how to use the iOS AEP Mobile SDK in applications. For more details see Getting Started.
- You should have CocoaPods installed.
Adding the Mobile SDK to your App Extension works the same way as adding the Mobile SDK to your application.
- In the Podfile, add a new target for your app extension and include the Adobe pods:
target 'YourApp' do
pod 'AEPServices'
pod 'AEPCore'
pod 'AEPLifecycle'
pod 'AEPIdentity'
pod 'AEPAnalytics'
end
target 'YourAppExtension' do
pod 'AEPServices'
pod 'AEPCore'
pod 'AEPLifecycle'
pod 'AEPIdentity'
pod 'AEPAnalytics'
end
- Run
pod install
from the command line to install the pods to the App Extension target.
This tutorial uses the ShareExtension
as the example.
{% hint style="info" %} Depending on the type of App Extension you are using, the registration and usage of the SDK will look different. Make sure you understand the lifecycle of your App Extension in order to know where best to register the SDK and call lifecycle start/pause. {% endhint %}
- Make sure that your
ShareViewController
has the proper imports for the SDK.
import UIKit
import Social
import AEPCore
import AEPIdentity
import AEPAnalytics
import AEPLifecycle
- Register the SDK in the
ShareViewController
'spresentationAnimationDidFinish
method:
override func presentationAnimationDidFinish() {
MobileCore.registerExtensions([Identity.self, Lifecycle.self, AnalyticsAppExtension.self], {
MobileCore.configureWith(appId: "your-app-id")
MobileCore.lifecycleStart(additionalContextData: nil)
})
}
{% hint style="info" %}
Please note that in order to register AEPAnalytics, you must use the AnalyticsAppExtension
class instead of the Analytics
class used when registering from an application.
{% endhint %}
- Managing lifeycle from a Share Extension should be done in the
didSelectCancel
anddidSelectPost
methods which are the delegate methods called when the ShareViewController is dismissed.
override func didSelectCancel() {
MobileCore.lifecyclePause()
}
override func didSelectPost() {
MobileCore.lifecyclePause()
...
}
You are now ready to use the SDK in your App Extension.