node.js - 在一个连接中从 node.js 向多个用户发送苹果推送通知

标签 node.js apple-push-notifications

我见过 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/

相关文章:

ios - 本地通知在应用程序关闭时不更新角标(Badge)编号

c# - 从 C# 连接到 node.js 服务器

javascript - BCRYPTJS : returning same hash for different passwords

node.js - 发布到 node-sass 和 Docker

iOS Firebase 消息没有收到

apple-push-notifications - AWS SNS 支持基于 token 的 APN 连接

php - 只有一半的推送通知到达设备 (APNS)

javascript - 回调中的空数组

html - 多人游戏是否应该始终根据每个客户端请求从数据库中请求数据?

ios - 应用程序发送旧推送和新推送