Migrating a native app to a RN/Expo app: keep user authenticated - react-native

I want to migrate an existing Android+iOS native app to a react-native Expo app.
In current native app, we store an auth token. I'd like this auth token to be available through ReactNative AsyncStorage api out of the box, without requiring RN native code (ie, ejecting Expo).
Is this possible, in current native app, to start writing to the same place as AsyncStorage will read after the migration?
We aim for the smoothest transition from native app to RN app, and user should stay authenticated after the upgrade.

Depends on what you're current app is using for storage. I recently used this library (https://github.com/kevinresol/react-native-default-preference) to get the data from user defaults then move it into async storage. I only migrate the refresh token and auth token.
If they are using core data, then you'll need to setup the same models etc - https://github.com/realm/realm-js/issues/584
The other storage mechanisms you can easily find a native package to get the data.

if the app is under same app name scheme you may be able to access after upgrade i guess.

Related

Getting localStorage from Ionic application in my React Native app

We are rebuilding an Ionic 1.x application with React Native. The app is used by a lot of people and I don't want everyone to log in again after they update the app.
The current app uses localStorage to save the token that defines if a user is logged in (I know, it's not the safest method). Is there a possibility that we can get the current token from the localStorage in React Native and put in our secure storage?
So basically can we call the localStorage instance in React Native? We are using the same bundle identifier so many there is a possibility to access the localStorage from the old app.
You wont treat with a web enviroment like Ionic, then localStorage wont exist, but you can use AsyncStorage instead in react native or some DB like sqlite, realm, whatermelonDB (the last one I didnt use) to save your user data

React Native & Cosmos DB - How to get them working together?

There seem to be no direct support for React Native through Cosmos DB SDK or npm packages. The JS package #azure/cosmos while works on React Native for the Web, but does not build for the native apps. It fails to build due to Cryto incompatibility.
While Resource Tokens can serve as a solution for authentication, but App still needs to interact with the DB resources using an API.
So, how to go around this? Is utilizing Azure Functions as a mid-tier the only workaround?
Thanks
If you need basic functionality like querying, creating new items etc, you can get the react-native-azure-cosmos package.
However the functionality is a very limited subset of the full JS SDK.
There is no official SDK for now to target react native applications.
You will need to use an API App or Function app to interact with CosmosDB and call the HTTP endpoints from your device.

how to integrate google login without firebase in bare Expo App

I want to implement Google login in my ejected expo App as per doc it requires google-services.json file from firebase which I don't have. I already implement whole backend logic on my server so i just need successful token after login.
I also check expo-google-auth but after installation, it giving me an error that emulator not found(lib issue).
so how can I implement google login without Firebase.

How to connect my react native app to existing database using Amplify?

I have react native app that already at the store.
I decided to move my database and my frontend and backend using Amplify.
I would like to connect my react native app using Amplify too, my needs are to check if user is sign in and get access token, refresh token, token expired date, sign out and using the different apis on the backend to get data...
I was looking on different documents like this one but couldn't find a way to connect to exist one, the only option I have seen is to create a new database only for the mobile...
What are my options? I thought maybe I should create login and refreshToken functions in the backend and only call those functions every time I need to log in or refresh a token... or maybe I should use configuration file somewhere? I was thinking about this file awsExports but not sure this is the right one, there's no explanation about it
Thanks in advance

Can you interact with the app in test using absolute positioning in Detox?

I am trying to test a react native app on android which uses a native library which does oauth-based authentication using a webview. Detox does not support webviews (yet) so I was wondering if I could tap on the keyboard using coordinates in order to get through the auth (bad I know, but gets me unstuck for now).
Since the oauth screen is outside your app, I'd recommend you do the following:
Create E2E tests for your login up to the oauth screen
Get a CLI for your oauth provider or figure out how to authenticate via node.js to get the auth token
Create a deep link path in your app that accepts the token as a param and stores it the way you'd store it normally and trigger a continuation of the login flow (you may need to reverse engineer your native lib slightly)
This is generally the approach you want to take if you are using an external authentication party. If the party providing the auth package doesn't support 2 and 3, you should raise the issue with them.