2015-10-17 49 views
0

我使用GCM将通知消息从我的服务器推送到Android和iOS设备。如何使用InstanceID从服务器端发送通知? - 带有.NET服务器的GCM

目前我使用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这是以前使用的,并已弃用现在任何的例子吗?

回答

1

总之在服务器端,你可以把InstanceIds以同样的方式你没有RegistrationIds,InstanceIds可能比RegistrationIds变化更为频繁,但由于RegistrationIds改变以及应该不会影响到你的服务器。

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

当使用InstanceId而不是RegistrationId时,服务器端应该没有变化。

2-我目前的实施会发生什么变化?

我不是一个尖锐的专家,但我不认为任何东西都需要在这里改变。 InstanceId是与RegistrationId相同的应用程序实例标识符。

是否有任何如何使用InsanceId而不是以前使用过的RegisterationId的示例,现在已被弃用?

Here is an example in java其中如果存在to字段被设置为InstanceId。我假设推锋正在做类似的事情。

+0

是的,我已经检查了pushSharp代码,这是几乎相同的过程,这是在这里发布的java代码,所以我会尝试推送消息到IID令牌而不是注册ID,它应该工作,但!谢谢你的这个好回答 – MBH

+0

使用InstanceId而不是RegistrationId工作完美! – MBH

相关问题