2015-06-03 46 views

回答

10

使用content_available(不content-available)属性是这样的:

curl -X POST --header "Content-Type:application/json" --header "Authorization:key=AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "https://android.googleapis.com/gcm/send" --data-ascii '{"data":{"xxx":"yyy"},"content_available":true,"to":"XXXXXXXXXX:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY-ZZZZZZZZZZZZZZZZZZZZ"}' 
+2

@black_stallion https://developers.google.com/cloud-messaging/server-ref搜索content_available – TheWonderBird

4

从您的服务器,您需要将content-available属性值为1添加到您的aps字典中。

您需要在您的Info.plist文件添加到remote-notificationUIBackgroundModes为这些无声的通知的支持。更多详情here

0

我使用node-gcm NPM库及以下的有效载荷对我的作品的iOS(Android设备我送一个稍微不同的有效载荷):

{ dryRun: false, 
    data: 
    { customKey1: 'CustomValue1', 
    customKey2: 'CustomValue2', 
    content_available: '1', 
    priority: 'high' }, 
    notification: 
    { title: 'My Title', 
    icon: 'ic_launcher', 
    body: 'My Body', 
    sound: 'default', 
    badge: '2' } } 

当然,你需要确保你的应用程序可以处理入站通知。

相关问题