1

这是我第一次围绕推送通知做所有事情。我用iOS实现了GCM,一切正常。但我的问题是我无法为我的应用创建好的有效载荷。我使用邮递员发送推送通知。这是我的内容:iOS Google Cloud Messaging有效负载

{  
    "registration_ids":["1234"], 

    "data": {"aps":{"alert":"Hello, world!","sound":"default", "content-available":"1"}} 
} 

问题是我的用户信息获取字典 “APS”:

enter image description here

如何正确地发送消息。我的userInfo没有“content-available”,因此我的(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler未被调用。如何正确测试它?

回答

1

你做错了。如果您通读了server documentation,您将看到您需要使用“通知负载支持”。

所以,你的内容应该是这样

{ 
    "registration_ids" : ["1234"], 
    "notification" : { 
    "title" : "Hello, world!", 
    "sound" : "default", 
    }, 
    "content_available" : 1, 
}