0
我想在測試項目上設置Parse推送通知。如何設置分析客戶端推送通知
我遵循了推送設置教程/指南。
我已啓用客戶端推送在Parse儀表板。
我已經更新了的.plist
我已經設定了目標和項目生成設置代碼簽名設置。
我通過發推:
PFPush.sendPushMessageToChannelInBackground("global", withMessage: "First push ever") { (success: Bool!, error: NSError!) -> Void in
...
}
當我嘗試從
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
有無設置我的配置配置文件和發送推我收到以下錯誤
Error Domain=Parse Code=115 "The operation couldn’t be completed. (Parse error 115.)" UserInfo=0x1764cad0 {code=115, error=Client-initiated push isn't enabled.}
證書不正確?有沒有辦法檢查這個?我有沒有設置錯誤地解析appDelegate?有沒有辦法檢查這個?
我的應用程序委託是這樣的:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Parse.setApplicationId("xxx", clientKey: "xxx")
var userNotificationTypes = (UIUserNotificationType.Alert | UIUserNotificationType.Badge)
var settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
var currentInstallation = PFInstallation.currentInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.channels = ["global"]
currentInstallation.save()
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
if error != nil {
println(error)
}
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
PFPush.handlePush(userInfo)
}
func applicationDidBecomeActive(application: UIApplication) {
var currentInstallation = PFInstallation.currentInstallation()
if currentInstallation.badge != 0 {
currentInstallation.badge = 0
currentInstallation.saveEventually()
}
你如何發送推送通知?我還沒有開始使用Swift,但看着你的代碼,我沒有看到你從客戶端發送推送通知的位置。如果您的應用向其他設備發送推送通知,則只需激活「啓用客戶端推送」即可。 – 2015-01-15 18:44:56
我已更新問題以包含推送請求 – grabury 2015-01-15 19:53:32
錯誤115表示推送在服務器上配置錯誤。你在Parse上配置了你的證書嗎?他們是正確的類型(開發與產品)?解析應該在推送區域告訴你你上傳了哪種類型的證書 - 確保你的應用程序版本使用相同的類型。 – rickerbh 2015-01-18 23:04:10