FCM设备组iOS应用徽章更新会导致Android上的空推

目标; 通过包含Android和iOS设备的FCM设备组以静默方式更新iOS应用程序徽章计数器。

问题; 设备组中的所有Android设备都会收到用户可见的无内容推送。

我已经尝试了很多不同的方法,但我正在努力寻找解决scheme。

使用遗留的http-api与身体{"to":"someToken", "notification":{"badge": "23"}}我成功地静默更新iOS应用程序徽章,但在同一设备上的任何已注册的Android设备组也收到一个没有任何内容的推送消息,这对用户是可见的。

您可以直接设置apns的V1 API不会出现支持设备组。 当我在token字段中设置设备组令牌时,api返回200,但没有任何反应。 不过,在将“单一设备”设置为设备组令牌时,我可以从Firebase通知控制台发送消息,这使得我认为这应该是可能的,但是我以某种方式做错了。

根据这个文档 ,你应该能够使用传统API的消息types数据结构,但我似乎无法得到它的工作。

以下是我的一些testing方法。


HTTP v1发送请求的API代码;

 import * as rp from 'request-promise' var options: any = { method: 'POST', uri: 'https://fcm.googleapis.com/v1/projects/' + FCMProjectName + '/messages:send', headers: headers, // Header gotten by means described here; https://firebase.google.com/docs/cloud-messaging/auth-server json: true, body: experimentalBody }; rp(options) .then(function(result){ console.log("result", result) }) 

遗留代码本质上非常相似,但是不同的URI和不同的标题。

我曾尝试过几个experimentalBody 。 我甚至无法得到与设备组一起工作的简单情况。

 experimentalBody = { message: { token: "validDeviceGroupToken", notification: { "title":"Check out this sale!", "body":"All items half off through Friday" } } } 

我也试过了;

 experimentalBody = { token: "validDeviceGroupToken", notification: { title:"Check out this sale!", body:"All items half off through Friday" } } 

设定优先顺序时不再有运气;

 experimentalBody = { message: { token: "validDeviceGroupToken", notification: { title:"Test!", body:"This is a test" }, apns: { headers: { "apns-priority": "10" } }, android: { priority: "HIGH" } } 

所有这些都返回success { name: 'projects/my-project/messages/' } ,但它看起来好像应该已经返回类似success { name: 'projects/my-project/messages/SOMETHINGHERE' }

使用传统api,下面的代码在iOS上工作,但向android发送空的通知;

 experimentalBody = { to: "validDeviceGroupToken", notification: { badge: 23 } } 

我也尝试使用遗留代码中的V1的message对象,但它似乎不工作。 我得到了一个body: "to\n"的回应body: "to\n" ,我怀疑这意味着我需要“在身体”,但我不知道。