BackendlessUser Properties update without login()

Dear Backendless-Team,
I hope you can help me with my question:
I have got the following behavior with my iOS App (Swift):
1.) User logged in into Backendless Server successfully
2.) All the user data including the properties is queried into a local instance <BackendlessUser>
3.) Now a property (e.g. “firstname”) is modified by an ViewController and also updated
self.backendless.userService.currentUser.setProperty(“firstname”, object: textField.text!)
self.backendless.userService.update(self.backendless.userService.currentUser)
4.) Now the property “firstname” is modified in Backendless Server and also in the local user instance <BackendlessUser>
Issue:
If the same user is logged in to Backendless Server in parallel on another device, those instance <BackendlessUser> of the other device is not updated. It will only updated after logout > login process.
I tried to solve it with doing a kind of update on each ViewController which I use “firstname”, to prevent login / logout. But I don´t find such an update method.
Could you please give me a hint how to update the user instance?
Thank you very much in advance.
Best Regards
Michael

Hi Michael,

You could try this approach to load the user object:

Types.tryblock({ () -> Void in
        
  let dataQuery = BackendlessDataQuery();
 // query to load user object which has objectId as the currently logged in user
  dataQuery.whereClause = "objectId = '\(backendless.userService.currentUser.objectId)'"


 // find operation always returns a collection
  let collection:BackendlessCollection = backendless.data.of(BackendlessUser.ofClass()).find(dataQuery)
        
  // take the first object from the collection, since there is always going to be just one
   let userObject = collection.getCurrentPage().first as! BackendlessUser;


  // that object is your update user
   print( "user object - \(userObject.objectId )")
 },
catchblock: { (exception) -> Void in
                print("Server reported an error: \(exception as! Fault)")
})

Dear Mark,

thank you so much, it works!

I used the getProperty() method to lad my specific User Properties (e.g. “firstname”).
self.textField.text = userObject.getProperty(“firstname”) as! String

Thank you very much!

Best regards
Michael