ios - Azure Notification Hub Registered Device list -


i following this post work azure notification hub. trying creating web api registers devices azure notification hub. when send request registering device shown in article hits azure notification hub.

below screen shot of azure portal. shows there request registration.

but when try details of registered devices using following code 0.

var registrationscount = await hub.getallregistrationsasync(int32.maxvalue); return registrationscount.count().tostring(); 

now have few questions :

1 ) how can explore registered device details ?

2 ) how can send test notification ios devices end. below code using send test notifications.

 var payload = string.format(toasttemplate, message);   hub.sendapplenativenotificationasync(payload, "worldnews"); 

3 ) if using web api end necessary configure ios app details in azure notification hub ? i.e uploading certificate , other details on azure portal ?

enter image description here

your first problem how calling getallregistrationsasync. parameter not maximum count of registrations want back. it's index of first registration want. under scenarios, 0, not int32.maxvalue

see: https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.notificationhubs.notificationhubclient#microsoft_azure_notificationhubs_notificationhubclient_getallregistrationsasync_system_int32_

public task<collectionqueryresult<registrationdescription>>      getallregistrationsasync(int top) 

bear in mind, also, method returns maximum of 100 registrations. if want more, you'll need use continuationtoken.

here's code use registrations:

internal async task<list<registrationdescription>> getallregistereddevicesasync() {     var hub = notificationhubclient.createclientfromconnectionstring(         settings.default.azurenotificationsmobileappfullsharedaccesslistenerconnection,         settings.default.azurenotificationsmobileapphubname,         settings.default.azurenotificationstestsendmode);      var allregistrations = await hub.getallregistrationsasync(0);     var continuationtoken = allregistrations.continuationtoken;     var registrationdescriptionslist = new list<registrationdescription>(allregistrations);     while (!string.isnullorwhitespace(continuationtoken))     {         var otherregistrations = await hub.getallregistrationsasync(continuationtoken, 0);         registrationdescriptionslist.addrange(otherregistrations);         continuationtoken = otherregistrations.continuationtoken;     }      return registrationdescriptionslist; } 

note method should only used if have few hundred, perhaps few thousand registrations. if have tens, hundreds of thousands or millions of registrations, should not use method, , find more efficient method find need.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -