Control Notification bridging on Android watch

In Android 5.0 (Lollipop), Google announced bridged notifications for wearables. Notifications and their actions (i.e what happens when you tap on a notification) are bridged over to the wearable devices by default. However all the actions cannot be achieved with a single tap on the watch. So mobile developers need a way to hide some of the notifications from appearing on the watch, and conversely allow some notifications to bridge over to the watch. IBM MobileFirst v6.3.0 added support for bridging control of notifications.


You can now include a new optional field in GCM properties of notification options when the notification is sent from the Adapter.

For broadcast and tag based notification :

1
2
3
4
5
6
7
8
9
function sendNotification(applicationId, notification, notificationText) {
   notification.message = {};
   notification.message.alert = notificationText;
   notification.settings = {};
   notification.settings.gcm = {};
   //turn this true or false for a notification to be bridged to the watch
   notification.settings.gcm.bridge= 'false'; //(true,false)
  WL.Server.sendMessage(applicationId, notification);
}

For Event Source notifications:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function submitNotification(userId, notificationText){
   var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);
   if (userSubscription==null){
      return { result: "No subscription found for user :: " + userId };
         }
   var badgeDigit = 1;
   var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"});
  //turn this true or false for a notification to be bridged to the watch
   notification.GCM.bridge = 'false'; //
   WL.Server.notifyAllDevices(userSubscription, notification);
   return {
      result: "Notification sent to user :: " + userId
      };
}
Last modified on May 01, 2016
Share this post: