【问题标题】:How to Send Push Notification to a specific user on Notification Hub?如何在通知中心向特定用户发送推送通知?
【发布时间】:2016-08-03 17:12:48
【问题描述】:

有什么方法可以向特定用户发送通知?我尝试使用 deviceToken。但是我找不到任何教程来展示我可以向设备令牌发送通知的方式。

【问题讨论】:

    标签: php ios azure push-notification azure-notificationhub


    【解决方案1】:

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

    当经过身份验证的用户注册推送通知时,用户 ID 标签会自动添加到注册中。通过使用此标签,您可以向特定用户注册的所有设备发送推送通知。

    您可以创建一个与表关联的 EasyTable 脚本,以存储经过身份验证的用户 ID。您可以利用以下代码 sn-p 来实现:

    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>");
    

    【讨论】:

      【解决方案2】:

      您将拥有一个设备令牌来发送推送。有几种方法可以获取设备令牌。以下示例将对您有所帮助。

      https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-aspnet-backend-windows-dotnet-wns-notification/

      【讨论】:

        【解决方案3】:

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

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

        How to use Notification Hubs from PHP 会告诉你如何在 PHP 中做到这一点。

        另外,看看它所指的this answerthe sample

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

        【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-19
        • 1970-01-01
        • 1970-01-01
        • 2020-12-24
        相关资源
        最近更新 更多