我的应用处于后台模式时,我没有收到任何通知.但是当它在前景时我可以看到它们.
对于GCM的测试功能,我使用它:
curl -X POST -H "Authorization: key= KKKKKKKKKKKK" -H "Content-Type: application/Json" -d '{"to":"XXXXXXXXX","data":{"message": "It is special push notification for test!!!"}}' https://gcm-http.GoogleAPIs.com/gcm/send
我看到此消息(如果应用程序处于活动状态).
但是当我使用它时:
curl -X POST -H "Authorization: key= KKKKKKKKKKK" -H "Content-Type: application/Json" -d '{"to":"XXXXXXXX","data":{"message": "It is special push notification for test!!!"},"notification":{"body":"great match!","Title":"Portugal vs. Denmark","icon":"myicon"}}' https://gcm-http.GoogleAPIs.com/gcm/send
在这种情况下,我没有看到消息.
您知道如何通过GCM发送通知,该通知会在应用关闭时显示吗?
附:看起来GCM不适用于APN.
解决方法 您需要将优先级参数发送为高,以通知ios设备.对于proirity的描述是;
Sets the priority of the message. ValID values are “normal” and
“high.” On iOS,these correspond to APNs priority 5 and 10.By default,messages are sent with normal priority. normal priority
optimizes the clIEnt app’s battery consumption,and should be used
unless immediate delivery is required. For messages with normal
priority,the app may receive the message with unspecifIEd delay.When a message is sent with high priority,it is sent immediately,and
the app can wake a sleePing device and open a network connection to
your server.
但我认为这不是一个足够的描述.
我为Java创建了一个library,它的测试用例在前台,后台或未运行时通知苹果设备.
总结以上是内存溢出为你收集整理的如何通过GCM向iOS设备发送推送通知?全部内容,希望文章能够帮你解决如何通过GCM向iOS设备发送推送通知?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)