I update a property on the User class after they register for Push notifications like so:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
backendless.messagingService.registerDevice([backendless.messagingService.currentDevice().deviceId], expiration: nil, token: deviceToken, response: { (deviceRegId) -> Void in
UserManager.saveUserWithDeviceId({ (fault) -> Void in
})
}) { (fault) -> Void in
//
}
}
The saveUserWithDeviceId method you see above is defined like so:
class func saveUserWithDeviceId(completed : (fault : Fault?) -> Void) {
let backendless = Backendless.sharedInstance()
let currentUser = Backendless.sharedInstance().userService.currentUser
currentUser.setProperty("deviceId", object: backendless.messagingService.currentDevice().deviceId)
backendless.userService.update(currentUser, response: { (updatedUser) -> Void in
print("Successfully updated user: \(currentUser)")
}) { (fault) -> Void in
print("Server reported an error: \(fault)")
}
}
Now sometimes it works, but most often it doesn’t go through and the following error messages are printed in my console:
Server reported an error: FAULT = '-1001' [NSURLErrorDomain] <The request timed out.>
error in __connection_block_invoke_2: Connection interrupted
error in __connection_block_invoke_2: Connection interrupted
Am I missing something?