我见过 Node 模块“node-apn”,但我不知道如何在一个连接中向多个用户发送相同的通知?我还看到可以在 PHP 中完成,但我使用的是 node.js
最佳答案
使用 node-apn v1.3.x(强烈推荐的升级),您可以向许多设备发送相同的通知,而根本不需要循环。该模块将自动处理有关向您的多个设备发送一个通知的复杂问题。
// Instantiate a new message
// and set message defaults
var note = new apns.Notification();
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 3;
note.sound = "ping.aiff";
note.alert = "You have a new message";
note.payload = {'messageFrom': 'Caroline'};
// List of user tokens
var userTokens = ['token1', 'token2', 'token3'];
// Send the message
apnsConnection.pushNotification(note, userTokens);
关于node.js - 在一个连接中从 node.js 向多个用户发送苹果推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14724471/