You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OneSignal Subscription ID能否兼容Player ID API?集成问题排查

问题分析与解决方案

核心问题:参数不匹配

你在Android端获取的是Subscription ID,但Node.js代码中使用了旧版的include_player_ids参数——这个参数仅适用于OneSignal的旧版Player ID。新版API中,Subscription ID需要使用include_subscription_ids参数。

修正后的Node.js代码

notification.app_id = config.ONESIG_APP_ID;
// 替换为适配Subscription ID的参数名
notification.include_subscription_ids = subscriptionIds;
notification.contents = {
  en: message,
};
client
  .createNotification(notification)
  .then((result) => {
    resolve(result);
  })
  .catch((error) => {
    // 打印错误详情,方便定位具体问题
    console.error('推送失败详情:', error);
    resolve({ status: 'Failure', error: error.message });
  });

额外排查点

  • 验证ID有效性:检查数据库中存储的Subscription ID是否完整,无截断或篡改。可在OneSignal后台「订阅者」列表中搜索该ID,确认其存在且状态正常。
  • 环境一致性:确保Android端和Node.js端使用的是同一个OneSignal App ID,区分开发与生产环境的ID。
  • 订阅状态检查:确认目标设备未取消推送订阅,也未卸载应用。
  • 数组格式验证:subscriptionIds必须是字符串数组(如["xxxx-xxxx-xxxx"]),而非单个字符串。

内容的提问来源于stack exchange,提问作者jamesmungai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 13:23:16