Start a new topic
Answered

Create autogenerated user in iOS 10 / Xcode 8

Hello there,


I have build an app that fetches some resources from my kinvey app envirnment. It was working in Xcode 7 when I was running iOS 9 on the simulator, but now I've updated to Xcode 8-beta and iOS10 on the simulator-beta, and I'm seeing some strange behaviour.


In appDelegate I create a user like this:


// Create user credentials if this havn't aldreay been done

if KCSUser.activeUser() == nil {

    KCSUser.createAutogeneratedUser(

        nil,

        completion: 

        { (user: KCSUser!, errorOrNil: NSError!, result: KCSUserActionResult) -> Void in

            print("Got new User ID: \(user.userId)")

        }

    )

    while KCSUser.activeUser() == nil { /* Busy wait for user */ }


} else {

    print("#### active user: \(KCSUser.activeUser())")

}


Every time I run the app, it creates a new user. I didn't have this problem in Xcode 7.


But okay, I have the user, so I should be able to download the resources. But when I call:

store.queryWithQuery(query, withCompletionBlock: ..., withProgressBlock: nil)


I get the following error in "errorOrNil" in the completion block:

    Error Domain=KCSServerErrorDomain Code=401 "Invalid credentials. 

    Please retry your request with correct credentials"


Next time I'm trying to run the same store.queryWithQuery method, I get code 401 again, but another message:

    Domain=KCSNetworkErrorDomain Code=401 "No Authorization Found"

 

To me it looks like it doesn't store the user credentials properly in the keychain.

What should I try to make it work?


Again, this was working fine before I updated to Xcode 8

I'm running:

Xcode Version 8.0 beta 2 (8S162m)

iOS 10.0





Best Answer

Updating to SDK 1.41.1 removed the problem.


Hello,


Which version of the Kinvey SDK are you using?


Thanks,


Billy

Sorry, i forgot to mention that, its 1.40.9.. Also, I finally got to run it on the device (also running iOS 10.0), and it seemed to work fine. It seems like the problem may be in the simulator..
Martin,

Does resetting the simulator make any difference?

Just wanted to confirm that the query works fine with iOS 10 on a phone but the issue is only seen while using the app with an iOS 10 simulator? Also you do not see any errors while creating the user on the iOS 10 simulator?

Thanks,
Pranav
Kinvey Support

 

Answer

Updating to SDK 1.41.1 removed the problem.

Hello Martin,


We're glad to hear it. Thanks for letting us know.


Regards,


Billy Gee

Login or Signup to post a comment