Node.js GCM推送通知允许的ID号码?

我做了一些search,找不到这个问题的答案,对不起,如果它是重复的。

我正在使用Node.JS向Android设备发送GCM通知。 我将注册ID列表传递给一个数组,然后通过Sender.send函数发送它。 我想知道, 每个发送请求所允许的ID数量是否有最大限制? 在发送function中每1000个电话一样,还是不存在这样的限制?

我记得阅读有关使用JSON格式一次发送多达1000个ID,是否适用于Node.JS中的node-gcm模块?

提前致谢。

GCM服务器将接受最多1000个注册ID的请求。 如果您有超过1000个,则必须将它们分成多个请求。

因此,你的问题的答案取决于你所调用的代码是否为你分裂。

node-gcm不允许发送超过1,000个设备。

请注意,您最多可以一次向1000个注册ID发送通知。 这是由于GCM API的限制。

https://github.com/ToothlessGear/node-gcm/issues/42

你可以很容易地将令牌分成批处理,如下所示:

 // Max devices per request var batchLimit = 1000; // Batches will be added to this array var tokenBatches = []; // Traverse tokens and split them up into batches of 1,000 devices each for (var start = 0; start < tokens.length; start += batchLimit) { // Get next 1,000 tokens var slicedTokens = tokens.slice(start, start + batchLimit); // Add to batches array tokenBatches.push(slicedTokens); } // You can now send a push to each batch of devices, in parallel, using the caolan/async library async.each(batches, function (batch, callback) { // Assuming you already set up the sender and message sender.send(message, { registrationIds: batch }, function (err, result) { // Push failed? if (err) { // Stops executing other batches return callback(err); } // Done with batch callback(); }); }, function (err) { // Log the error to console if (err) { console.log(err); } });