Starting with WatchOS 2, your WatchKit Extensions can run on an Apple Watch. Applications that run in this environment require the WatchConnectivity framework to share data with their containing iOS app.
Tip: Starting with
AdobeMobileLibraryv4.6.0,WatchConnectivityis supported.
Looking for information and documentation related to the Adobe Experience Platform Mobile SDK? Click here for our latest documentation.
As of September 2018, we released a new, major version of the SDK. These new Adobe Experience Platform Mobile SDKs are configurable through Experience Platform Launch.
- To get started, go to Adobe Experience Platform Launch.
- To see what is in the Experience Platform SDK repositories, go to Github: Adobe Experience Platform SDKs.
Important: Ensure that you have a project with at least the following targets:
- The containing app
- The WatchKit app
- The WatchKit extension
For more information about developing WatchKit apps, see The Watch App Architecture.
Complete the following steps in your Xcode project:
-
Drag the
AdobeMobileLibraryfolder into your project. -
Ensure that the
ADBMobileConfig.jsonfile is a member of the containing app’s target. -
In the Build Phases tab of your containing app’s target, expand the Link Binary with Libraries section and add the following libraries:
AdobeMobileLibrary.alibsqlite3.tbdSystemConfiguration.framework
-
In your class that implements the
UIApplicationDelegateprotocol, add theWCSessionDelegateprotocol.#import <WatchConnectivity/WatchConnectivity.h> @interface AppDelegate : UIResponder <UIApplicationDelegate, WCSessionDelegate>
-
In the implementation file of your app delegate class, import the
AdobeMobileLibrary.#import "ADBMobile.h"
-
Before making a call to the
ADBMobilelibrary, inapplication:didFinishLaunchingWithOptions:of your app delegate, configure yourWCSession.// check for session availability if ([WCSession isSupported]) { WCSession *session = [WCSession defaultSession]; session.delegate = self; [session activateSession]; }
-
In your app delegate, implement the
session:didReceiveMessage:andsession:didReceiveUserInfo:methods.syncSettings:is called in theADBMobilelibrary, which returns a bool that indicates whether the dictionary was meant for consumption by theADBMobilelibrary. If it returnsNo, the message was not initiated from the Adobe SDK.- (void) session:(WCSession *)session didReceiveMessage:(NSDictionary<NSString *,id> *)message { // pass message to ADBMobile if (![ADBMobile syncSettings:message]) { // handle your own custom messages } } - (void) session:(WCSession *)session didReceiveUserInfo:(NSDictionary<NSString *,id> *)userInfo { // pass userInfo to ADBMobile if (![ADBMobile syncSettings:userInfo]) { // handle your own custom messages } }
-
Ensure that the
ADBMobileConfig.jsonfile is a member of your WatchKit extension’s target. -
In the Build Phases tab of your WatchKit extension’s target, expand the Link Binary with Libraries section and add the following libraries:
AdobeMobileLibrary_Watch.alibsqlite3.tbd
-
In your class that implements the
WKExtensionDelegateprotocol, importWatchConnectivityand add theWCSessionDelegateprotocol.#import <WatchConnectivity/WatchConnectivity.h> @interface ExtensionDelegate : NSObject <WKExtensionDelegate, WCSessionDelegate>
-
In the implementation file of your extension delegate class, import the
AdobeMobileLibrary.#import "ADBMobile.h"
-
In
applicationDidFinishLaunchingof your extension delegate, configure yourWCSessionbefore making any calls to theADBMobilelibrary.// check for session availability if ([WCSession isSupported]) { WCSession *session = [WCSession defaultSession]; session.delegate = self; [session activateSession]; }
-
In
applicationDidFinishLaunchingof your extension delegate, initialize the watch app for the SDK.[ADBMobile initializeWatch]; -
In your extension delegate, implement the
session:didReceiveMessage:andsession:didReceiveUserInfo:methods.syncSettings:is called in theADBMobilelibrary, which returns a bool that indicates whether the dictionary was meant for consumption by theADBMobilelibrary. If it returnsNO, the message was not initiated from the Adobe SDK.- (void) session:(WCSession *)session didReceiveMessage:(NSDictionary<NSString *,id> *)message { // pass message to ADBMobile if (![ADBMobile syncSettings:message]) { // handle your own custom messages } } - (void) session:(WCSession *)session didReceiveUserInfo:(NSDictionary<NSString *,id> *)userInfo { // pass userInfo to ADBMobile if (![ADBMobile syncSettings:userInfo]) { // handle your own custom messages } }
Remember the following information:
- For WatchKit apps,
a.RunModewill be set toExtension. - Because WatchKit apps run on the watch, the apps will correctly report their names in
a.AppID. - No lifecycle call is triggered on WatchOS2 apps.