android device specific push notifications by using azure mobile services

做~自己de王妃 提交于 2019-12-11 23:54:03

问题


I have a mobile service in azure and an android application. I want to send push notification on user device who is registering it self. I got success on sending notifications through gcm but it is broadcasting the notifications on all devices. Please help me in this regard.

for sending notification I have customized insert query in azure but it is broadcasting the notifications. I have no idea how to send it in specific device.

my insert query is-

function insert(item, user, request) {
      var payload = '{"data":{"message" : "Hello from Mobile Services!"}}';
      request.execute({
           success: function() {
          // If the insert succeeds, send a notification.
             push.gcm.send(null, payload, {
             success: function(pushResponse) {
             console.log("Sent push:", pushResponse, payload);
             request.respond();
            },              
        error: function (pushResponse) {
            console.log("Error Sending push:", pushResponse);
            request.respond(500, { error: pushResponse });
            }
        });
    },
     error: function(err) {
     console.log("request.execute error", err)
     request.respond();
     }
 });
}

回答1:


The first parameter to your call to push.gcm.send is null. This tells the push engine to push to any device that has registered to your service for GCM push. You can change this by either passing in the registration ID of the specific device you want to push to or look at how Notification Hubs work with Tags.



来源:https://stackoverflow.com/questions/23495195/android-device-specific-push-notifications-by-using-azure-mobile-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!