Start a new topic
Answered

Error on Login (NSErrorWrapper). Nativescript with Kinvey

Hi! 


Im starting using kinvey with nativescript & angular, so i have a very simple sample project where i want to make a login, so i started the library correctly and is working cuz im able to create users with the signup method, the problem is when i try to log in, im always getting an error: 


"NSErrorWrapper: One or more parameters passed to a function were not valid"


Im using Nativescript 3.4.0 along with Angular 5 and the kinvey sdk 3.9.10 .


*Note: Event though the documentation say's that there's 2 ways of do a login (https://devcenter.kinvey.com/nativescript/guides/users#login), im just able to use the first method (where i need to send two parameters username, and password) if i try to send an object i get a compilation error.


Best Answer

Hello Christofer, 


From the described error, I assume that you are testing your project in iOS simulator.

 

If that is the case, this is a known issue which affects the iOS simulators with iOS 11. It occurs because the Kinvey SDK is using a secure storage on iOS to save the active user details. This native iOS piece of functionality is not handled well in (all) iOS simulators. For example, the issue is always occurring with the latest Xcode (9.x.x) and iOS device simulator with iOS 11. It is working as expected on a physical iOS device.

 

Even that for best results it is always recommended to use an actual physical device you may sometimes need to use the iOS simulator. To work around the issue in the iOS simulator you may consider one of the following approaches:

  • add the Keychain Sharing capability via an entitlements file in your app's App_Resources/iOS directory as shown in one of the recent versions of the NativeScript template - https://github.com/NativeScript/template-master-detail-kinvey/blob/master/App_Resources/iOS/app.entitlements. Note that usually you do not need to use this setting in your production app if you do not need the Keychain Sharing enabled between your apps, however, this enables the simulator to "simulate" the access to this secure storage. It can be removed when you are moving your application package to production and publishing (given that you might not need to enable that Keychain Sharing in your app(s)).
  • create a simulator device with iOS 9
  • open the Xcode project of the NativeScript app and enable the Keychain Sharing capability for the app then run the app in the simulator from Xcode

 

Let me know if this has helped or if you are not using iOS simulator for testing the project.


Best,

Anton 

 


Thanks a lot!! totally helpful! taking the first approach, works perfectly for me


Regards!

Answer

Hello Christofer, 


From the described error, I assume that you are testing your project in iOS simulator.

 

If that is the case, this is a known issue which affects the iOS simulators with iOS 11. It occurs because the Kinvey SDK is using a secure storage on iOS to save the active user details. This native iOS piece of functionality is not handled well in (all) iOS simulators. For example, the issue is always occurring with the latest Xcode (9.x.x) and iOS device simulator with iOS 11. It is working as expected on a physical iOS device.

 

Even that for best results it is always recommended to use an actual physical device you may sometimes need to use the iOS simulator. To work around the issue in the iOS simulator you may consider one of the following approaches:

  • add the Keychain Sharing capability via an entitlements file in your app's App_Resources/iOS directory as shown in one of the recent versions of the NativeScript template - https://github.com/NativeScript/template-master-detail-kinvey/blob/master/App_Resources/iOS/app.entitlements. Note that usually you do not need to use this setting in your production app if you do not need the Keychain Sharing enabled between your apps, however, this enables the simulator to "simulate" the access to this secure storage. It can be removed when you are moving your application package to production and publishing (given that you might not need to enable that Keychain Sharing in your app(s)).
  • create a simulator device with iOS 9
  • open the Xcode project of the NativeScript app and enable the Keychain Sharing capability for the app then run the app in the simulator from Xcode

 

Let me know if this has helped or if you are not using iOS simulator for testing the project.


Best,

Anton 

 

Thanks for answer!


You are totally right! it was an entitlements issue, after enable the Keychain Sharing Capability through Xcode everything worked fine, im wondering if the angular version might be related also, cuz i tried with https://github.com/KinveyApps/sample-Groceries and i was able to login using the emulator to the same Kinvey app with the same Xcode version and the same device emulator(iOS 11), i mean i didn't have to do all of this entitlements stuff, the only difference is the angular version. Do you think that could cause this behavior????

Hi Christofer, 


God to hear that worked on your side. 


Seems the sample app used a similar approach and used to add the entitlements from here - https://github.com/KinveyApps/sample-Groceries/blob/master/app/App_Resources/ios/app.entitlements 


I do not think this may be affected by the Angular version, it mostly relates to the way the Kinvey SDK uses the native Keychain storage to persists user data and how this storage is available/or not in the simulator. 


In addition, as per this PR there is also another way to workaround the simulator issue instead of adding entitlements - https://github.com/KinveyApps/sample-Groceries/pull/3/commits/60db923e73dfe9668e1e2a1330ff9419294baa67, however, I am not sure which approach may be more maintainable/easier on your side. 


Let me know if this helps. 


Best,

Anton 

Login or Signup to post a comment