tôi đang cố gắng để có được phân tích cú pháp thông báo đẩy làm việc trên ứng dụng của tôi (tất cả nhanh chóng) nhưng trong khi cố gắng thực hiện, tôi nhận được lỗi 'PFInstallation' does not have a member named 'saveInBackground'
Parse Đẩy Thông báo - Lắp đặt Swift không làm việc
Đây là mã của tôi.
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)
}
Khi tôi thay đổi currentInstallation.saveInBackground
để currentInstallation.saveEvenutally()
, mã biên dịch tốt ..
Nhưng khi cố gắng đăng ký thành công cho thông báo đẩy, một lỗi bật lên trong giao diện điều khiển nói Error: deviceType must be specified in this operation (Code: 135, Version: 1.4.2)
tôi đã dành nhiều giờ cố gắng để tìm ra điều này, không có xúc xắc, bất kỳ trợ giúp được đánh giá cao.
Điều này vẫn không sửa chữa nó cho tôi: (, làm điều này + var currentInstallation: PFInstallation = PFInstallation.currentInstallation() làm việc – yoshyosh
'nhập khẩu Bolts' Đó là nó –