正如标题所说,我有我的所有注册ID的列表,我想发送相同的消息对所有这些一次。
As the title says, I have a list of all my registration IDs, and I want to send the same message to all of them at once.
我被告知,GCM可以一次处理大约1000通知,但我真的很困惑,如何做到这一点的 PushSharp
(除个别实际上他们发送,使用for循环)。如果任何人都熟悉这个我真的AP preciate一些帮助。
I was told that GCM can handle approximately 1000 notifications at once, but I'm really confused as to how to do this in PushSharp
(other than actually sending them individually, using a for loop). If anyone is familiar with this I would really appreciate some assistance.
他的一些通用code
He's some generic code
push.RegisterGcmService(new GcmPushChannelSettings(ApiKey));
push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(RegistrationID)
.WithJson(json));
而不是有1注册ID的,我想在他们的名单发送。引用常见问题解答,但是,如何做到这一点没有实际的答案。
Instead of having 1 registration ID i'd like to send in a list of them. References to FAQ's but no actual answer on how to do so.
参考1
参考2
参考3
我从来没有用过夏普推,但是的在此基础上code :
I've never used Push Sharp, but based on this code :
您目前正在使用这种方法,它接受一个注册ID:
You are currently using this method, which accepts a single Registration ID :
public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, string deviceRegistrationId)
{
n.RegistrationIds.Add(deviceRegistrationId);
return n;
}
使用这个方法来代替,该接受多个注册的ID:
Use this method instead, which accepts multiple Registration IDs :
public static GcmNotification ForDeviceRegistrationId(this GcmNotification n, IEnumerable<string> deviceRegistrationIds)
{
n.RegistrationIds.AddRange(deviceRegistrationIds);
return n;
}