【问题标题】:how to use InstanceID to send notification from Server Side ? - GCM with .NET server如何使用 InstanceID 从服务器端发送通知? - 带有 .NET 服务器的 GCM
【发布时间】:2015-10-17 08:25:56
【问题描述】:

我使用 GCM 将通知消息从我的服务器推送到 Android 和 iOS 设备。

目前我正在使用PushSharp 库,就是这样使用的:

string senderId = "my server id from google console";
string device_regId = "some device id";

//Create our push services broker
var push = new PushBroker();

//Registering the GCM Service and sending an Android Notification
push.RegisterGcmService(new GcmPushChannelSettings(senderId));

push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(device_regId)
                      .WithJson("{\"message\":\"TestMessage!\",\"badge\":1}"));

我在谷歌上读过InsanceID Documentation

问题

1- 如何在服务器端使用它?

2- 我当前的实现会发生什么变化?

3- 是否有任何示例说明如何使用 InsanceID 而不是之前使用但现在已弃用的 RegisterationId?

【问题讨论】:

    标签: c# android wcf google-cloud-messaging pushsharp


    【解决方案1】:

    简而言之,在服务器端,您可以像对待 RegistrationIds 一样对待 InstanceIds,InstanceIds 的更改可能比 RegistrationIds 更频繁,但这不会影响您的服务器,因为 RegistrationIds 也发生了变化。

    1- 如何在服务器端使用它?

    使用InstanceId代替RegistrationId时,服务器端应该没有变化。

    2- 我当前的实现会发生什么变化?

    我不是一个精明的专家,但我认为这里也没有什么需要改变的。 InstanceId 是与 RegistrationId 相同的应用程序实例标识符。

    是否有任何示例说明如何使用 InsanceId 而不是以前使用但现在已弃用的 RegisterationId?

    Here is an example in java 其中 to 字段设置为 InstanceId(如果存在)。我假设 push sharp 在幕后做了类似的事情。

    【讨论】:

    • 是的,我检查了 pushSharp 代码,这与您在此处发布的 java 代码中的过程几乎相同,所以我将尝试将消息推送到 IID 令牌而不是注册 ID,它不过应该可以!谢谢你的精彩回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    相关资源
    最近更新 更多