Start a new topic

How to refresh custom user

Hi


Could you please help me to refresh costume user?

  

    appKey: "kid_Bym8FF-A7",
            appSecret: "dc0d4dfb85bf4608ad4826a254c97066"
        ) {
            switch $0 {
            case .success(let user):
                if let customUser = user as? CustomUser {
                  customUser.refresh()

  Doesnt work for me 

1 Comment

Hi Wood,


Please try using the following code snippet to refresh the custom user:


Kinvey.sharedClient.userType = CustomUser.self
   
Kinvey.sharedClient.initialize(
            appKey: "kid_SkmEzxxxx",
            appSecret: "f72aa24333e747feb4c25af35f3xxxxx"
        ) {
            switch $0 {
            case .success(let user):
                print("entered success block")
                if let user = user {
                    print("\(user)")
                }
            case .failure(let error):
                print("entered error block")
                print("\(error)")
            }
        }


let myUser = Kinvey.sharedClient.activeUser as! CustomUser
print("Active User's username:  \(String(describing: myUser.username))")
print("id of the logged in user is:  \(String(describing: myUser.userId))\n\n\n\n")

Kinvey.sharedClient.activeUser?.refresh() { result in
               switch result {
               case .success:
                      print("User refreshed successfully")
               case .failure(let error):
                      print(error)
                                    }
        }




Thanks,

Pranav

Kinvey

Login or Signup to post a comment