Edit in GitHubLog an issue

iOS App Extension implementation

You can use supported Adobe Experience Platform mobile extensions in your App Extensions to collect usage data. The supported Platform mobile extensions are listed here.

Prerequisites

  • 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 AEP mobile extensions

Adding the Mobile SDK to your App Extension works the same way as adding the Mobile SDK to your application.

  1. In the Podfile, add a new target for your app extension and include the Adobe pods:
Copied to your clipboard
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
  1. Run pod install from the command line to install the pods to the App Extension target.

Registering Extensions

This tutorial uses the ShareExtension as the example.

  1. Make sure that your ShareViewController has the proper imports for the SDK.
Copied to your clipboard
import UIKit
import Social
import AEPCore
import AEPIdentity
import AEPAnalytics
import AEPLifecycle
  1. Register the SDK in the ShareViewController's presentationAnimationDidFinish method:

Swift

Copied to your clipboard
override func presentationAnimationDidFinish() {
MobileCore.registerExtensions([Identity.self, Lifecycle.self, AnalyticsAppExtension.self], {
MobileCore.configureWith(appId: "your-app-id")
MobileCore.lifecycleStart(additionalContextData: nil)
})
}
  1. Managing lifecycle from a Share Extension should be done in the didSelectCancel and didSelectPost methods which are the delegate methods called when the ShareViewController is dismissed.

Swift

Copied to your clipboard
override func didSelectCancel() {
MobileCore.lifecyclePause()
}
override func didSelectPost() {
MobileCore.lifecyclePause()
...
}

You are now ready to use the SDK in your App Extension.

Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.