Create Apple Watch notifications
Integrate the Apple Watch SDK with your Apple Watch app
Overview
The iOS SDK includes an Apple Watch SDK that you can integrate with your Apple watch app. When you integrate the SDK, you can send mobile app messages to your Apple Watch customers. The SDK can thus maximize your engagement with app users. Your app users can take immediate action with Apple Watch notifications.
You can enhance your Apple Watch notifications to include images and maps. Each notification offers a layout with a header image or logo, title, body, and map or background image. You can customize the notification's color, text, alignment, and style.
Before you begin
Before getting started, integrate the SDK with your iOS app. For more information, see Add the iOS SDK to your app.
Add the Watch App Target to your existing iOS application
- Open your project in XCode.
- Go to File > New > Target.
- Select the watchOS Template tab.
- Select the WatchKit App template and then click Next.
- Enter a name and team.
- Enable notifications by verifying that Include Notification Scene is checked.
- Click Finish.
Link the Watch SDK into your Watch app
Drag the AcousticMobilePushWatch.xcframework
file from the SDK download into your watch project.
Integrate the Watch SDK into the Watch app code
- Copy
HandOffController.h
andHandOffController.m
to your WatchKit Extension from the Plugins/watchOS directory. - Open the NotificationController.h / NotificationController.swift file under the new watch extension.
- Add the following import statement to the header import section:
@import AcousticMobilePushWatch;
import AcousticMobilePushWatch
- Change the superclass for
NotificationController
toMCENotificationInterfaceController
.
@interface NotificationController : MCENotificationInterfaceController
class NotificationController: MCENotificationInterfaceController {
- Open the ExtensionDelegate.m / ExtensionDelegate.swift file under the new watch extension.
- Add the following import statement to the header import section:
@import AcousticMobilePushWatch;
import AcousticMobilePushWatch
- Add the following to the top of the
applicationDidFinishLaunching
method:
[MCEWatchSdk.sharedInstance applicationDidFinishLaunching];
MCEWatchSdk.shared.applicationDidFinishLaunching
- Add the following to the top of the
applicationDidBecomeActive
method:
[MCEWatchSdk.sharedInstance applicationDidBecomeActive];
MCEWatchSdk.shared.applicationDidBecomeActive()
- Add the following to the top of the
applicationWillResignActive
method:
[MCEWatchSdk.sharedInstance applicationWillResignActive];
MCEWatchSdk.shared.applicationWillResignActive()
Integrate the Watch SDK into your Watch app interface
- Open the
Interface.storyboard
of the WatchKit App. - Delete the
Static Notification Interface Controller
andNotification Controller Scenes
from yourInterface.storyboard
. - Open the
Interface.storyboard
in the Plugins/watchOS directory. - Copy the
HandOff
,Static Notification Interface Controller
, andNotification Controller Scenes
from the plugin'sInterface.storyboard
to yourInterface.storyboard
.
Note:
The category name for the
HandOff
controller can be customized in the MceConfig.json file.
Complete the watch configuration
- Open the application's info.plist file.
- Add the NSUserActivityTypes key and an array with the com.mce.application string.
Note:
The string can be customized in the MceConfig.json file.
- Open the MceConfig.json file.
- Expand the file inspector panel.
- Add the MceConfig.json file to the watch application and to the watch extension.
- Open the Build Settings tab for the watch extension and add -ObjC to the Other Linker Flags option.
The Watch SDK is integrated with your watch app allowing you to send notifications to Apple Watch.
Enable Newsstand to send mobile app messages
You can use the iOS SDK with the Apple Newsstand app to send mobile app messages. The messages can also include publications on Newsstand.
- Set up your app as a Newsstand. for more information, see the developer documentation from Apple.
- Update the JSON payload to include the content-available property with a value of 1.
Note:
App users can disable the background downloads initiated by the mobile app messages. The background downloads are limited to only one in 24 hours.
For troubleshooting and technical notes that are related to Newsstand, go here.
Updated over 1 year ago