2016-08-03 78 views

回答

1

根据上https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-node-backend-how-to-use-server-sdk/#push-user的描述:

当推送通知已认证的用户寄存器,一个用户ID标签被自动添加到注册。通过使用此标签,您可以将推送通知发送到特定用户注册的所有设备。

您可以创建与表关联的EasyTable脚本来存储经过验证的用户ID。您可以利用下面的代码来实现这一点:

table.insert(function (context) { 
    context.item.userId = context.user.id; 
    return context.execute(); 
}); 

参考https://github.com/Azure/azure-content/blob/master/articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md#how-to-adjust-the-query-that-is-used-with-table-operations更多。

然后用这个PHP sample与用户ID发送通知:

$hub = new NotificationHub("<connectionString>", "<hubName>"); 
$message = '{"data":{"message":"Hello from PHP!"}}'; 
$notification = new Notification("gcm", $message); 
$hub->sendNotification($notification, "_UserId:sid:<UserId>"); 
0

你可以做,使用tags。将唯一标签与每个用户相关联,然后向该标签发送通知。

Azure Notification Hubs Notify Users for iOS with .NET backend是一步一步的教程,让您了解如何使用标签。

How to use Notification Hubs from PHP会给你和想法如何在PHP中做到这一点。

另外,看看this answerthe sample它是指。

准备好原型后,请使用Diagnosis guidelines解决任何问题。

+0

的问题是我尝试商店标签,但什么也没有发生在Azure的门户网站。这里是发送'[NSSet setWithObjects:@“user,nil];'的对象。 – TheZozoOwner

+0

哦,Notification Hubs标签与您在Azure Portal中看到的Azure Resource Manager标签不同。这真的很让人困惑,看看[我的答案](http://stackoverflow.com/a/38534891/182371)[为什么Azure Notification Hub标记不保存?](http://stackoverflow.com/questions/36335644/ why-are-azure-notification-hub-tags-not-saving/38534891#38534891)澄清它。另外请看[使用服务总线浏览器调试通知集线器](https://msdn.microsoft.com/en-us/library/azure/dn530751.aspx#sb_explorer)。 –