Azure Notification Hub: notifications not showing up if sent to group

帅比萌擦擦* 提交于 2019-12-13 04:43:57

问题


I have a trouble making notification hub to work.

If I send notification to tag that has only one registration associated with it, then everything's fine. Here's source:

var alert = "{\"aps\":{\"alert\":\"some message(targeted)\"},\"inAppMessage\": \"text\"}";
hub.SendAppleNativeNotificationAsync(alert,"mytag").ContinueWith(t => {
    var outcome = t.Result;
    Console.WriteLine(outcome);
});

But if I try to sent my notification to all users, like so:

var alert = "{\"aps\":{\"alert\":\"some message(all users)\"},\"inAppMessage\": \"text\"}";
hub.SendAppleNativeNotificationAsync(alert).ContinueWith(t => {
    var outcome = t.Result;
    Console.WriteLine(outcome);
});

then no one gets the notification. I checked monitor in Azure portal but there were no errors present.

Do you guys have some ideas?


回答1:


Behavior you described is incorrect. There is one known issue which can potentially cause such kind of errors for Apple only:

If some registrations in the Notification Hub have invalid device token (it typically happens when application switches from test APNS to production or if some fake tokens were used during testing in emulator) then APNS terminates connection during the send and all notifications being sent after that using same connection are just ignored. Right now Notification Hub does not handle this situation correctly.

Way to fix - clean up "bad" registrations. If you are about developing/testing and it is not critical to lose the data - just remove all the registrations. If you have a lot of existing users then email me and we will try to find solution for your particular case.




回答2:


I had same issue and I tried to set true EnableTestSend property, but no luck. Then I just removed the tags while send notifications. It worked like charm.

 NotificationOutcome outcome = null;
  var alert = "{\"aps\":{\"alert\":\"" + "From " + user + ": " + message + "\",\"sound\":\"default\"}}";
outcome = await Notifications.Instance.Hub.SendAppleNativeNotificationAsync(alert);


来源:https://stackoverflow.com/questions/25789831/azure-notification-hub-notifications-not-showing-up-if-sent-to-group

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!