如何让所有设备注册programaticaly? [英] How to get all devices registered programaticaly ?

查看:64
本文介绍了如何让所有设备注册programaticaly?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,只通过GetAllRegistrationsAsync获取100台设备,仅限ios 并且通过标记方式不获取延续令牌GetRegistrationsByTagAsync

By default getting only 100 devices through GetAllRegistrationsAsync that to only ios  and through tag wise not getting continuation token GetRegistrationsByTagAsync

推荐答案

GetAllRegistrationsAsync不是最大注册数。为了使用它,你需要设置一个循环。

如果你想超过100个注册,你需要使用ContinuationToken。

You'll need to use the ContinuationToken if you want beyond 100 registrations.

下面是一些示例代码,可以实现100多个注册。如果您有其他问题或疑虑,请告诉我们。

Below is some sample code to achieve more than 100 registrations. Please let us know if you have further questions or concerns.

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;
}


这篇关于如何让所有设备注册programaticaly?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆