Android设备的具体推送通知用湛蓝的移动服务 [英] android device specific push notifications by using azure mobile services

查看:130
本文介绍了Android设备的具体推送通知用湛蓝的移动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure中的移动业务和Android应用程序。我想送谁是注册它自身用户设备上的推送通知。我通过GCM发送通知成功,但它是广播在所有设备上的通知。请帮我在这方面。

发送通知,我已经定制插入查询在蔚蓝的,但它是广播通知。我不知道如何在特定设备发送。

我的插入查询是 -

 插入函数(项目,用户要求){
      VAR有效载荷='{数据:{消息:你好!从移动服务}}';
      request.execute({
           成功:函数(){
          //如果插入成功,发送通知。
             push.gcm.send(NU​​LL,有效载荷,{
             成功:函数(pushResponse){
             的console.log(已发送推:pushResponse,负载);
             request.respond();
            },
        错误:功能(pushResponse){
            的console.log(错误发送推:pushResponse);
            request.respond(500,{错误:pushResponse});
            }
        });
    },
     错误:功能(错误){
     的console.log(request.execute错误,错误)
     request.respond();
     }
 });
}


解决方案

第一个参数您来电push.gcm.send为null。这告诉推送引擎推到已注册到您的服务GCM推送的任何设备。您可以通过在你要推到或看通知集线器如何与标签工作特定设备的注册ID,要么通过改变这一点。

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();
     }
 });
}

解决方案

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.

这篇关于Android设备的具体推送通知用湛蓝的移动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆