Skip to content
This repository has been archived by the owner on Aug 31, 2019. It is now read-only.

Cannot log in users on iOS simulator #31

Closed
tjvantoll opened this issue Feb 14, 2018 · 14 comments
Closed

Cannot log in users on iOS simulator #31

tjvantoll opened this issue Feb 14, 2018 · 14 comments

Comments

@tjvantoll
Copy link

tjvantoll commented Feb 14, 2018

@toddanglin is putting together a template for NativeScript that uses Kinvey. As he was developing the template, and as I was testing it, we both hit a rather bizarre issue where a call to Kinvey.User.login() works on physical devices, but fails on iOS simulators (details below).

Steps to Reproduce

Follow the steps to test Todd’s template here. To make testing easier you can use an app key of "kid_HJUbdabvM", an app secret of "4a1ef9127ce24912a23f792b22831daf", a username of "foo", and a password of "foo".

Run the app on an iOS simulator and attempt to log in using the credentials "foo" and "foo".

Expected Result

The user logs in successfully and navigates to another page.

Actual Result

An error, and this in the console.

CONSOLE LOG file:///app/login/login.component.js:25:24: Login Event
CONSOLE LOG file:///app/login/login.component.js:39:24: Attempt Login
CONSOLE WARN file:///app/login/login.service.js:19:29: Login failure. NSErrorWrapper: One or more parameters passed to a function were not valid
CONSOLE WARN file:///app/login/login.component.js:54:33: Login failed

If you then run the exact same app with zero changes on a physical device the code log in should work exactly as expected—because reasons?

Version of Kinvey NativeScript SDK

3.9.10

Kinvey AppKey

(posted earlier)

NodeJS version

6.12.2

This is an odd one, and I wouldn’t believe this was happening if it hadn’t happened to both Todd and me. Hopefully this write up wasn’t too confusing, and if you need more details or help recreating this let me know.

@toddanglin
Copy link

@tejasranade Putting on your radar since this is pretty critical to the Identity Connect on-boarding process

@tejasranade
Copy link
Contributor

@toddanglin looking at it now.

@tejasranade
Copy link
Contributor

tejasranade commented Feb 14, 2018

@toddanglin @tjvantoll
The app needs an app.entitlements file under App_Resources/iOS/. Example.

For some reason, the keychain access API on simulator expects this file. I need to dig further why that's the case; and if we can insert it ourselves during the SDK install. Ideas welcome :)

With the app.entitlements file in the right place, I confirmed that the login code works as expected.

@tjvantoll
Copy link
Author

@tejasranade Thanks for the crazy quick response here! You’re absolutely right and I confirmed that adding that file fixes the issue. I’ll do some checking with the CLI team tomorrow about whether this can be automated with a hook like you suggest. I’ll reply back in here.

@tjvantoll
Copy link
Author

tjvantoll commented Feb 14, 2018

Checked with @rosen-vladimirov. He reminded me that {N} plugins can totally just include a platforms/ios/app.entitlements file and the {N} CLI will automatically merge that in during the build. You should be able to add that file to this plugin and it’ll be included in every app that uses the Kinvey SDK.

@tejasranade
Copy link
Contributor

Awesome! We'll add that in. Anything to be mindful of, for apps that already have that file?

@toddanglin
Copy link

That's great news.

Looking at root cause, I wonder why the iOS Simulator requires this entitlement but actual iOS devices do not? I don't see much harm in just including the entitlement by default, but probably worth a root cause pass to see if it may impact other areas of the SDK...

@tjvantoll
Copy link
Author

I don’t think there would be any repercussions of including an app.entitlements file, even if it’s only needed for the simulator, but this is an area of iOS land where I don’t have any experience. cc @rosen-vladimirov

Out of curiosity, has this come up before with either the Appcelerator / Ionic / native iOS Kinvey SDKs? Just wondering if there’s any existing documentation and/or research we could use to get some background on what specifically is going on here.

@rosen-vladimirov
Copy link

Hey guys,
It should be fine to use the app.entitlements in the plugin. Even if the project already has such file, CLI will merge the project file with the one from the plugin.

@tejasranade
Copy link
Contributor

We found the root cause of this issue. It appears that the NativeScript cli adds an entitlements file, and corresponding entry in the Xcode build settings, by default during the iOS build process. This file is only added for the Debug configuration.

We tried overwriting this file in one of our samples, and we saw the issue go away. See KinveyApps/sample-Groceries#3

@rosen-vladimirov @tjvantoll this is something the CLI team should look into. We think the default entitlements file and the setting should not be necessary.

Hat tip to @heyzooi for troubleshooting this issue!

@tjvantoll
Copy link
Author

Hey @tejasranade. Just fyi we saw this and our CLI team will get back with you next week. (They’re heads down getting the {N} CLI ready for a 4.0 RC release right now.)

@rosen-vladimirov
Copy link

Hey guys,
We have investigated this issue and we can confirm you are correct - in the default case, when you do not have any entitlements, CLI generates an empty file, that breaks the login in iOS Simulator. We'll handle this case, but I believe this will not fix the problem in general. What I mean - when you add only the kinvey-nativescript-sdk plugin, the login in iOS Simulator will work as expected. However, in case you add any other plugin, that has app.entitlements in it and it does not contain the keychain-access-groups in this entitlements file, the login in iOS Simulator will stop working.
So I recommend adding the default app.entitlements file in the plugin itself - this way we'll guarantee the plugin will work correctly no matter of the other plugins used in the app.
What do you think?

@bradmartin
Copy link

Just ran into this myself on a project. Drove me crazy for the past couple hours debugging and trying to see why iOS wasn't signing in. I'll add the entitlements file for now but commenting to make sure I get updated with the 'final' word here 😄

PS - Loving Kinvey so far 🎉

@tejasranade
Copy link
Contributor

@rosen-vladimirov makes sense, we'll add a default to the plugin. Stay tuned, that fix should be out soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants