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

PhoneGap Build安卓集成Pushwoosh插件收重复推送问题求助

Hey there, let's dig into why your PhoneGap Build app is getting duplicate push notifications when using the Pushwoosh plugin and sending via FCM's API directly. I've troubleshooted similar issues before, so here are the most likely causes and fixes:

可能的成因及对应解决方案

1. 设备存在多个有效FCM令牌

If your app has been updated, uninstalled/reinstalled, or has flawed registration logic, the device might generate multiple FCM tokens. If your server's token list doesn't clean up old invalid tokens in time, sending a push via FCM will deliver the message to all associated tokens, resulting in duplicates on the same device.

解决方法:

  • 用设备唯一标识(比如UUID、IMEI)关联令牌,每次获取新令牌后,删除该设备对应的旧令牌。
  • 调用FCM发送时,确保registration_ids数组里每个设备只保留一个有效令牌,或者使用to参数指定单个令牌发送。

2. Pushwoosh插件与直接FCM调用的冲突

Pushwoosh's Cordova plugin already integrates FCM's push handling logic. If your app has native FCM listening code at the same time, or the plugin's internal push processing duplicates your own FCM callbacks, the same message will be processed and displayed twice.

解决方法:

  • 检查应用代码,移除 all native FCM-related registration and callback logic, and only keep the push handling methods provided by Pushwoosh (such as pushwoosh.onPushReceived).
  • 考虑更新Pushwoosh插件版本:You're currently using 7.0.8, which is relatively old and may have compatibility issues. Try upgrading to the latest stable version (modify the plugin version number in config.xml) to see if the conflict is resolved.

3. 服务端代码重复发送请求

Sometimes the problem lies on the server side: it could be a code logic error that calls the FCM sending interface twice, or a retry mechanism that triggers duplicate requests. FCM will naturally push twice when receiving two identical messages.

解决方法:

  • 检查你的Curl code, make sure there are no repeated calls to curl_exec() or loop sending logic flaws.
  • Add a collapse_key parameter to each push request: FCM will merge duplicate messages based on this key, and only send once to the device even if multiple identical requests are received. For example, add this to the request body:
    "collapse_key": "unique_push_identifier"
    
  • Check the server logs to confirm whether two identical push requests were actually sent, and locate the root cause of the problem.

4. FCM的重复投递机制

FCM has its own retry mechanism. If no confirmation is received from the client after the first push (such as receipt loss due to unstable network), FCM will redeliver the message, causing duplicate reception.

解决方法:

  • Confirm whether the Pushwoosh plugin automatically handles FCM receipts: Usually, such plugins will send a confirmation to FCM after receiving a push to avoid duplicate delivery. If you're not sure, check the plugin documentation.
  • Set the time_to_live parameter when sending messages to limit the survival time of messages and avoid duplicate delivery of expired messages. For example, set it to 1 hour:
    "time_to_live": 3600
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:16:59