Apple Watch

Supporting Notifications

By default, all notifications from your iOS device will appear on your watch. This means there is nothing for developers to do in order to "support" Apple Watch.

Customize the Notification Interface

There are two types of customizations possible when it comes to notifications; custom and dynamic. To start, click your project and go to File > New > Target and select Apple watch. Be sure to tick "Include Notification Scene". Alternatively, you can add one to your existing watch app's storyboard by dragging in a NotificationController object, creating files and linking them up in the identity inspector.

Static Custom Notification Interfaces

This is the most basic type of customization you can do for your alert. For this, you can include static items such as text or images. This will mean that every alert you receive, this content will show. Content can be added directly in Interface Builder. This can be useful if you want to include some help text or branding in your alert. However, a dynamic interface will harness the true power of Apple Watch.

Dynamic Custom Notification Interfaces

In this type of interface, you can have the same text and image outlets as before, but now they can be populated via the content of a push payload from APNS. You can send content for extra text fields and images for display. You have the option to create actions (just like those from interactive notifications in iOS 8) also. To push custom APNS payloads in Sailthru Mobile push notifications, simply use the existing Key-Value Payloads feature.

Deep Linking from Apple Watch to iOS

To create a deep link such as a button that says "Read Message" from the alert, which takes the user to their Sailthru Mobile Message Stream, you need to combine two technologies; Interactive Notifications and Handoff.

Overriding Push Notification Registration

Sailthru Mobile automatically registers for authorization to display push notifications. To disable this, simply alter your startEngine method:

iOS (Objective-C)

[[SailthruMobile new] startEngine:@"Your_App_Key" withAuthorizationOption:STMPushAuthorizationOptionNoRequest];

iOS (Swift)

SailthruMobile().startEngine("Your_App_Key", with: .noRequest)
From here, you can register your own push notification settings. Settings include alert types (sounds, banners, alerts) as well as a category. With Interactive Notifications, you can declare a category of Notification types when registering for Notifications that include a "Read Message" action. An example is here.

Using Handoff

Inside
- (void)didReceiveRemoteNotification:(NSDictionary *)remoteNotification withCompletion:(void (^)(WKUserNotificationInterfaceType))completionHandler
you then create a handoff action to interact with the WatchKit app's host app.

iOS (Objective-C)

NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.myapp.ExampleApp.openstream"];
[self updateUserActivityState:userActivity];

iOS (Swift)

let userActivity = NSUserActivity(activityType: "com.myapp.ExampleApp.openstream")
self.updateUserActivityState(userActivity)
In your AppDelegate, implement continueUserActivity.

iOS (Objective-C)

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
    if ([userActity.activityType isEqualToString:@"com.myapp.ExampleApp.openstream]) {
      //Handle opening the stream, or any deep links you wish to open.
    }
  }

iOS (Swift)

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {    
    if userActivity.activityType == "com.myapp.ExampleApp.openstream" {
      //Handle opening the stream, or any deep links you wish to open.
    }
}
Apple Watch promises some exciting engagement opportunities for your users - be sure to follow the Human Interface Guidelines for Apple Watch to ensure a smooth and captivating experience.

Contact us

Top