我试图得到解析推送通知我的应用程序(所有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