我的问题是一样的,因为这一个:Android设备特定推送通知
android device specific push notifications by using azure mobile services
但我使用的.Net后端。这是我发送通知的部分:
Dictionary<string, string> data = new Dictionary<string, string>() { { "message", "this is the message" } };
GooglePushMessage message = new GooglePushMessage(data, TimeSpan.FromHours(1));
Services.Push.SendAsync(message);
但是没有办法传入注册ID。
UPDATE
我使用GooglePushMessage的有效载荷性能也试过:
GooglePushMessage message = new GooglePushMessage();
message.JsonPayload = JsonConvert.SerializeObject(new { registration_id = "blablabla", data = new { message = "77" } });
事实证明,这是忽略了registration_id财产,因为我仍然得到通知我的设备。
我想实现的是从第三方获取API调用,并使用存储在我的数据库中的注册ID将通知发送到特定设备。
您必须在该JSON对象内包含registration_id(我猜,消息是JSON对象)。 – user1728071 2015-02-09 11:38:14
在JSON对象中包含registration_id不会改变结果,我可以设置一个随机的registration_id,并且仍然会在我的设备上获取通知。 – DevMonster 2015-02-10 08:58:40
这很有趣。除非您在json中指定registration_id,否则GCM不会向所有人发送通知。发送JSON对象时一定有问题。发送到GCM时请检查消息内容。 – user1728071 2015-02-10 10:19:51