2015-05-01 164 views
1

我正在使用解析作爲我的iOS應用程序發送推送通知的後端。我的問題是,應用程序圖標收到推送通知後從未顯示徽章(除了徽章,一切工作正常)。應用程序徽章不顯示解析推送通知

我檢查在解析安裝DB的「徽章」字段,它與每一個推的增加,所以我覺得這可能是一個客戶端問題

這裏是我的雲代碼:

Parse.Push.send({ 
    where: pushQuery, 
    data: { 
     aps: { 
      alert: "Your friend " + request.user.get("Name") + " just joined VoiceMe!", 
      sound: "default", 
      AlertType: "NewFriend" 
     }, 
     badge: "Increment" 
    } 
}, { 
    success: function() { 
     /*all is good*/ 
    }, 
    error: function(error) { 
     outcome = false; 
     errorOutput = error; 
    } 
}); 

而且在我的應用程序的代碼:解析上安裝數據庫的

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { 
    let currentInstallation = PFInstallation.currentInstallation() 
    if PFUser.currentUser() != nil { 
     currentInstallation.setObject(PFUser.currentUser()!, forKey: kParseInstallationUserKey) 
    } 
    currentInstallation.setDeviceTokenFromData(deviceToken) 
    currentInstallation.channels = ["global"] 
    currentInstallation.saveInBackgroundWithBlock { (resultBool, error) -> Void in 
     println("register device: --- \(resultBool) ---- error: \(error)") 
    } 
} 

圖片: enter image description here

+0

徽章需要進入aps字典塊。不在其外面 – soulshined

+0

我試圖把它放在aps字典的外面,但它不會增加安裝數據庫中的徽章數量? – Lneuner

+0

這就是爲什麼我說它進入 – soulshined

回答

3

在這裏看到我的答案:https://stackoverflow.com/a/27615528/2353523僅供參考

您已經創建了自己的字典。這用於交互式通知等。徽章不在您創建的字典之外,它是用於發送推送的正確的字典。這就是爲什麼它不會在您在aps字典下創建的有效載荷中增加。你必須告訴它。否則,只需刪除aps字典並通過數據字典傳遞參數

+1

真棒,這個工程!謝謝! – Lneuner