通过GCM将安静通知推送到Android / IOS [英] push silent notification through GCM to Android/IOS
问题描述
例如,如果用户得到一个新的应用程序,就可以(或不能)来自他们的朋友之一的消息我想发送这样的消息并且能够显示具有声音的提示。
但是在无声情况下,我希望用户不要注意这样的通知。它必须由应用程序收集;例如,如果我的用户有两个设备,并且他在其中一个设备上更改他的名字,我想发送另一个设备(它正在休眠)一个无声名称更新,它应该在后台触发更改(分发到应用程序)。
据我所读到的,这实际上是可能的,但我对它的实际状况或应该如何完成感到很困惑,有时有些矛盾。作为后端开发人员,我可以做任何事情,但我需要确保它适用于前端人员。
这里有一些相关的主题:
Android: 请勿在您的有效内容中包含通知
标记,并在其中放入数据
标记,您将收到无声通知
这个例子会显示通知
{notification:{
title:Portugal vs. Denmark,
text:5至1
},
至:bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1 ...
}
这不会显示通知
{
to:bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1 ...,
data:{
Nick:Mario,
body:绝配!,
房间:PortugalVSDenmark
},
}
请点击此处阅读更多 https://developers.google.com/cloud-messaging / concept-options#notifications_and_data_messages
iOS
添加标记 contentAvailable:1
添加到您的json有效内容中,您将收到一个无声通知
其简单的
I'm seeking to send an state update to an application, which can (or not), be silent.
For example, if the user gets a new message from one of their friends I want to send such message and be able to display an alert with sound.
But in the silent case, I want the user not to notice such notification. it must be gathered by the application; for example if my user has two devices and he changes his name in one of them, I want to send the other device (which is sleeping) a silent name update, that should trigger a change (be dispatched to the application) in background.
According to what I've read this is actually possible, but I'm quite confused regarding to how it actually is, or how it should be done, and there are some contradictions at times. As a backend developer I can do anything but I need to make sure that it works for the frontend guys.
Here some relevant topics:
Silent background push on iOS and Android
Push Notifications without alert
iPhone push notification without alert
Android:
As long as you do not include a notification
tag in your payload and put a data
tag in it you get a silent notification
this example would show a notification
{ "notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
this would not show a notification
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
go here to read more https://developers.google.com/cloud-messaging/concept-options#notifications_and_data_messages
iOS
add the tag contentAvailable: 1
to your json payload and you get a silent notification
its that simple
这篇关于通过GCM将安静通知推送到Android / IOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!