2015-05-01 167 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