3

I want to subscribe multiple users to a device for push notification in MFP. which i assume is not possible.

So what I want to do is i want to send my notification on the basis of deviceid ignoring user. Is this possible.

I see two methods which send notification to a device, but they still need userid is what i see.

WL.Server.notifyDevice(userSubscription, deviceId, notification);
WL.Server.notifyDeviceSubscription(deviceSubscription, notificationOptions)

Is there any other way, Please suggest.

Rahul
  • 217
  • 1
  • 9

1 Answers1

3

Yes, You can send push notification targeted to deviceId using multiple ways.

  1. You can use sendMessage API where you can specify deviceIds in Target Parameter. In this case only those deviceIds will receive the notification.

  2. Send Message REST API where you need to add target as deviceIds.

The following is the payload example.

{
  "message" : {
    "alert" : "Test message",
  },
  "target" : {
    "deviceIds" : [ "MyDeviceId1", ... ]
  },
}
Vittal Pai
  • 3,317
  • 25
  • 36
  • Thank you Vittal. – Rahul Oct 04 '16 at 07:24
  • Vittal I have a small issue here i am sending the notification as you mentioned above . But when i receive the notification its calling onMessage() method but the props and payload of this method are empty i think i have to give it a tag name can you help what tag name can i give. How should i avoid this issue. – Rahul Oct 21 '16 at 09:21
  • @Bender Tag names are meant for tag based push notifications. Seems to be you are not passing any parameters other than message. Refer payload/properties example [here](https://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.apiref.doc/rest_runtime/r_restapi_send_message_post.html) . – Vittal Pai Oct 21 '16 at 09:36
  • I am sending notificationOptions.target.deviceIds =deviceIds ; and notificationOptions.message.alert = notificationText; I am receiving the notification i cant see the notification in the notification bar but the message is empty in onmessage method. – Rahul Oct 21 '16 at 10:02