Update User ID
Before any data synchronization, we need to set or configure a user to identify the data and know who owns the information. We recommend configuring this after your login using the updateUser function of UserManager as shown below.
info
Any call to upbdateUserId with a different userId will override the previous userID and reset the sync status, if
you are using BackgroundSync all health data will synchronize
again the next time the app is launched.
...
let userManager: UserManager = UserManager()
func addUser() {
...
userManager.updateUserId("USER-ID") { result in
switch result {
case .success(let success):
debugPrint("success \(success)")
case .failure(let failure):
debugPrint("error \(failure)")
}
}
...
}