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, 
}