Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用PushSharp在GCM中发送批通知_C#_Android_Push Notification_Google Cloud Messaging_Pushsharp - Fatal编程技术网

C# 如何使用PushSharp在GCM中发送批通知

C# 如何使用PushSharp在GCM中发送批通知,c#,android,push-notification,google-cloud-messaging,pushsharp,C#,Android,Push Notification,Google Cloud Messaging,Pushsharp,正如标题所说,我有一个所有注册ID的列表,我想一次向所有注册ID发送相同的消息 我被告知GCM一次可以处理大约1000个通知,但我真的很困惑如何在PushSharp中做到这一点(除了实际使用for循环单独发送它们)。如果有人对此很熟悉,我将非常感谢您的帮助 他是某种通用代码 push.RegisterGcmService(new GcmPushChannelSettings(ApiKey)); push.QueueNotification(new GcmNotification().ForDe

正如标题所说,我有一个所有注册ID的列表,我想一次向所有注册ID发送相同的消息

我被告知GCM一次可以处理大约1000个通知,但我真的很困惑如何在
PushSharp
中做到这一点(除了实际使用for循环单独发送它们)。如果有人对此很熟悉,我将非常感谢您的帮助

他是某种通用代码

push.RegisterGcmService(new GcmPushChannelSettings(ApiKey));

push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(RegistrationID)
                                  .WithJson(json));
我想发送一个注册ID列表,而不是一个注册ID。 参考常见问题,但没有实际的答案如何做到这一点


我从未使用过Push Sharp,但是:

您当前正在使用此方法,该方法接受单个注册ID:

public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, string deviceRegistrationId)
{
    n.RegistrationIds.Add(deviceRegistrationId);
    return n;
}
改为使用此方法,它接受多个注册ID:

public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, IEnumerable<string> deviceRegistrationIds)
{
    n.RegistrationIds.AddRange(deviceRegistrationIds);
    return n;
}
设备注册ID的公共静态GcmNotification(此GcmNotification n,IEnumerable DeviceRegistrationID)
{
n、 注册ID.AddRange(DeviceRegistrationID);
返回n;
}

我从未使用过Push Sharp,但是:

您当前正在使用此方法,该方法接受单个注册ID:

public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, string deviceRegistrationId)
{
    n.RegistrationIds.Add(deviceRegistrationId);
    return n;
}
改为使用此方法,它接受多个注册ID:

public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, IEnumerable<string> deviceRegistrationIds)
{
    n.RegistrationIds.AddRange(deviceRegistrationIds);
    return n;
}
设备注册ID的公共静态GcmNotification(此GcmNotification n,IEnumerable DeviceRegistrationID)
{
n、 注册ID.AddRange(DeviceRegistrationID);
返回n;
}

您需要使用它来获得扩展方法

using PushSharp;
using PushSharp.Android;
using PushSharp.Core;
然后你可以用

GcmNotification notification = new GcmNotification().ForDeviceRegistrationId(pRegistrationIds)
                                              .WithJson(pMessage);

您需要使用它来获得扩展方法

using PushSharp;
using PushSharp.Android;
using PushSharp.Core;
然后你可以用

GcmNotification notification = new GcmNotification().ForDeviceRegistrationId(pRegistrationIds)
                                              .WithJson(pMessage);

谢谢山姆的编辑!谢谢山姆的编辑!:)谢谢我让它工作,我发送了一个字符串列表,它接受了!这种方法向批处理设备发送一条消息。但是如何发送批处理通知?例如:我有20条不同的信息和20台设备。如何批量发送推送通知?:)谢谢!我让它工作,我发送了一个字符串列表,它接受了!这种方法向批处理设备发送一条消息。但是如何发送批处理通知?例如:我有20条不同的信息和20台设备。如何批量发送推送通知?