Logging to Device in Production React Native Expo App - reactjs

Question: How can we log messages and save it on the device for a production React Native Expo app?
Requirements
Store log files on the mobile device
(Ideally) Log rotation, compression and/or pruning
Log files can be sent to a remote server on-demand (ie. user clicked a button)
Candidates that are not suitable
Expo supports Sentry, but it is meant for crash reports.
Expo support Amplitude and Segment, but they are more for analytics.
Sentry, Amplitude & Segment are not suitable because we are looking more of an implementation that does logging and dumping the logs to a remote server on-demand. We can create our own node.js server to accept incoming log dumps as well, so a hosted service is not necessary.
Our app currently uses redux-persist, wondering if theres a solution (3rd-party library included) for logging to a persisted redux store compatible with React Native Expo apps?

if you want to do everything yourself without using third party library. Here is how I would suggest you to do it. make a function say logMessage(message) this function will write the message to asyncstorage with current date as the key. if any message is already logged for that particular date, this will append the message. and you can call this function wherever you want to log. to send the logs to remote server it is upto you whether you want to send the logs of the current date or multiple dates or all of the logs. you may also want to write function that clears all the logs. So AsyncStorage of react-native can do the work for you.

Related

Expo data encryption and large storage abilities

We are researching at using Expo to build an offline first app that requires medium storage and encryption.
It is an app comprising of several user filled forms and data tables.
The core requirements are:
Offline ability. Allowing the user to fill in several forms whilst offline and have the device push this data via POST requests when the device receives a connection.

So far we have a basic working offline app that utilises redux offline (https://github.com/redux-offline/redux-offline) to store client actions when the device is offline and automatically sync this when the device receives a connection.
Store a medium amount of JSON data (100MB+) for offline usage. The app needs to grab this data from a GET request and store it locally. The JSON data is used as part of the form journeys, allowing the user to select from predefined dropdown fields, etc. 

We are unsure how to approach this with Expo.
All the stored data must be encrypted. 

We are unsure how to approach this with Expo.
Authentication via Keycloak. 

This is proving difficult due to the lack of documentation on Expo. It seems it should be done via AuthSession (https://docs.expo.dev/versions/latest/sdk/auth-session/).

The storage and encryption requirements are proving particularly difficult to work around. Are these possible with Expo? Or would we need to eject for React Native for these? Any advice would be much appreciated. Thanks




listen to Firestore's onSnapshot while app is not running

I want my app to be able to listen to onSnapshot while it is in background , I know that I can use background task for this by I don't know how to set it up .
btw I'm trying to implment this so that my app can push a notification whenever a new doc is received while app is in the background .
Most mobile operating systems severely limit what the app can do while it is backgrounded. Keeping an active connection open to a server is one of those things that has never been allowed on iOS, and has gotten more restrictive with recent Android versions.
The better approach is to run the code that detects a relevant change on a server, and then use Firebase Cloud Messaging (or APNS directly if you're only targeting iOS) to send a notification to the user. When they they tap on that notification, your app is started and you can load the data from Firestore.
If you don't want to run your own server, Cloud Functions is a common alternative for this, as it has built in triggers that respond to changes in Firestore. For an example of this exact scenario, see the documentation on notify users when something interesting happens.

React Native firebase analytics app install tracking

For Example, i am using react-native-firebase library.
I want to grow my app install and i create a campaign.
The question is how can i know my app is installed by clicking ads or my app is downloaded directly on play store.
Simply i want to know where was my app downloaded from. I do implement firebase analytics configuration.
It seems like you could follow the advice given in this question: https://stackoverflow.com/a/47893179/4147687
Essentially, if all you want is simply a way to track how your app was installed, you can simply pass utm parameters along with your URL.
For example:
https://link-to-my-app.com/?utm_source=business_card&utm_medium=email&utm_campaign=sign_up_offer
Google Play has it's own URL builder to make this step easier here. If you are not using any specific ad network just set it as "Custom".
Firebase will automatically scrape the source, campaign and medium parameters there and present them to you in the first_open conversion event. Documentation for how this works is here.
The easiest way to do this is by using this npm package
https://www.npmjs.com/package/react-native-install-referrer
You should invoke the API only once during the first execution after install.
You can do that using AsyncStorage to check if its freshly installed or not and then you can logEvent based on that UTM url and track the users
After creating the event you can segregate users by creating Audiences in the firebase console.

How to do authentication in hybrid mobile app develped using Meteor, Ionic, Angular, ngCordova

What's the best way to implement authentication for mobile app that will be secure and also wont annoy the user by asking to authenticate every time the app starts? In other words, for the first time after installing the mobile app, the user needs to register/login, and after that the app always works without asking to authentication.
Native mobile applications ask for credentials when using the app for the first time, but subsequently they don't require login. The app just start and try to connect to data network (wifi, 3g, etc.), if it finds the data network then it loads the latest data, else uses the data that it was able to fetch last time it could get access the data network. Also, the app is able to reconnect automatically when data network is available and fetch the latest data with out user intervention.
I tried to develop similar features using meteor mobile app (accounts-password, useraccounts:core, useraccounts:ionic), however the app quite frequently times out and asks for re-login everytime the data network is lost. Sometimes it even hangs on the login screen and the only way out is to kill the app. The behavior seems very similar to a web app, where a session id is created and has an idle timeout, or forces login when internet connection has issues.
Any tips on how to store the credentials on first login and use it subsequent; and also good way of handling data network when disconnects are frequent?
Frameworks:
1. Meteor Platform
2. Ionic with AngularJS
3. ngCordova
Code Structure:
1. Common directory, where all the meteor method calls and schema definitions (simple schema).
2. Application files are organized as per guidelines (client,server, resources).
One of the solutions I found on stackoverflow:
Send the UDID or mac address with the initial login details to your server. create a unique token for this user/UDID (or mac) combination and send it back(encrypted) to the device if username/pass is successful. on subsequent access, the device sends the encrypted token and UDID/mac (over secure connection) for re-authentication.
if you want to put paranoid people at ease about tracking UDID, you could instead use the UDID/mac to salt the encrypted token, but this wont be as secure, but should do the job still.
Appreciate your help, thank you!

Using Heroku database and Shared Preferences for Android Social Networking App

Hi I am developing a social Networking app. I have an online heroku database where i can push and pull information. According to my research i would need to do this through a web service like REST and then retrieve the any info i want through JSON to my app; in a nut shell. My question is will I need to use android's Shared Preferences if I want to store a user's info like name,password,etc which would obviously be sent to my heroku database anyway. What is the point of Shared Preferences then?
There are a few reasons. These would include:
Unless you are going to make the user enter all his credentials every time he starts the app, you will need to store some of these locally (you could potentially avoid this by just keying off the device id, but what if the user has multiple devices?)
Save bandwidth. Local preferences (what things to show, theme options, which tab to start on), should be stored locally - especially if the user may have multiple devices which use your service. e.g. I might want my tablet to show a different default page on open to my phone.

Resources