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

  1. Open your project in XCode.
  2. Go to File > New > Target.
  3. Select the watchOS Template tab.
  4. Select the WatchKit App template and then click Next.
  5. Enter a name and team.
  6. Enable notifications by verifying that Include Notification Scene is checked.
  7. 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

  1. Copy HandOffController.h and HandOffController.m to your WatchKit Extension from the Plugins/watchOS directory.
  2. Open the NotificationController.h / NotificationController.swift file under the new watch extension.
  3. Add the following import statement to the header import section:
@import AcousticMobilePushWatch;
import AcousticMobilePushWatch
  1. Change the superclass for NotificationController to MCENotificationInterfaceController.
@interface NotificationController : MCENotificationInterfaceController
class NotificationController: MCENotificationInterfaceController {
  1. Open the ExtensionDelegate.m / ExtensionDelegate.swift file under the new watch extension.
  2. Add the following import statement to the header import section:
@import AcousticMobilePushWatch;
import AcousticMobilePushWatch
  1. Add the following to the top of the applicationDidFinishLaunching method:
[MCEWatchSdk.sharedInstance applicationDidFinishLaunching];
MCEWatchSdk.shared.applicationDidFinishLaunching
  1. Add the following to the top of the applicationDidBecomeActive method:
[MCEWatchSdk.sharedInstance applicationDidBecomeActive];
MCEWatchSdk.shared.applicationDidBecomeActive()
  1. 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

  1. Open the Interface.storyboard of the WatchKit App.
  2. Delete the Static Notification Interface Controller and Notification Controller Scenes from your Interface.storyboard.
  3. Open the Interface.storyboard in the Plugins/watchOS directory.
  4. Copy the HandOff, Static Notification Interface Controller, and Notification Controller Scenes from the plugin's Interface.storyboard to your Interface.storyboard.

📘

Note:

The category name for the HandOff controller can be customized in the MceConfig.json file.

Complete the watch configuration

  1. Open the application's info.plist file.
  2. Add the NSUserActivityTypes key and an array with the com.mce.application string.

📘

Note:

The string can be customized in the MceConfig.json file.

  1. Open the MceConfig.json file.
  2. Expand the file inspector panel.
  3. Add the MceConfig.json file to the watch application and to the watch extension.
  4. 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.

  1. Set up your app as a Newsstand. for more information, see the developer documentation from Apple.
  2. 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.