我試圖得到解析推送通知我的應用程序(所有SWIFT)工作,但在落實,我得到的錯誤'PFInstallation' does not have a member named 'saveInBackground'
解析推送通知 - 斯威夫特安裝不工作
這裏是我的代碼。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Parse.setApplicationId("APP ID HIDDEN", clientKey: "CLIENT ID HIDDEN")
// let notificationTypes:UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
//let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
var notificationType: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
//UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
// Override point for customization after application launch.
return true
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings!) {
UIApplication.sharedApplication().registerForRemoteNotifications()
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
var currentInstallation: PFInstallation = PFInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.saveInBackground()
println("got device id! \(deviceToken)")
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
println(error.localizedDescription)
println("could not register: \(error)")
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
PFPush.handlePush(userInfo)
}
當我改變currentInstallation.saveInBackground
到currentInstallation.saveEvenutally()
,代碼編譯好..
但是,試圖成功地註冊了推送通知時,錯誤控制檯說Error: deviceType must be specified in this operation (Code: 135, Version: 1.4.2)
我彈出花了數小時試圖弄清楚這一點,沒有骰子,任何幫助都很感激。
這仍然不能解決它:(我做這個+ var currentInstallation:PFInstallation = PFInstallation。currentInstallation()工作 – yoshyosh 2014-12-26 09:50:46
'進口螺栓' 就是這樣 – 2015-08-20 10:47:50