How do I update js file/code on App Launch - android

I want a react-native app, when started on a device to check for some update and download it and use it instead of old js file.
I have checked out Codepush but as an alternative I am searching for a simple and clean implementation for a small case usage.
I just want some js code/file to be updated without bundling the app again or updating it through playstore, maybe suggest some other options too.

Related

React Native Hot Reloading

I have created a React Application via Expo CLI, while I run something via:
yarn web
I am able to open a QR code, and Switch to Tunnel and open that application via my Personal Android Device, it renders fine. But I have to make any changes, and I spin the server again using the same command, it does not seem to refresh content. It does refresh on Web, but does not on Android.
I have gone through few SO's posts and seen that we need a Hot Reload to serve contents dynamically. But when I shake the phone rigorously, I do not find any thing such as Hot Reload to enable it.
This is what I am getting:
I need two things now so to unblock me:
How to enable Hot Reload?
How can I rebuild the package so that I can access the latest from Android mobile
I used expo start instead of yarn web,
And it has helped me in auto reloading

Capacitor.isNative changes value when reloading page in Webview or when restarting app

In the capacitor app we are developing for Android we load the entire app from a url using server.url in capacitor.config.json.
Our app is a single-spa application which loads angular apps as multiple microfrontends. We build our app using the commands:
npm run build (this builds the root config for single-spa)
npx cap sync android
npx cap open android
then build APK using Android Studio
Then we try doing the following code in one of our angular components. It is done to conditionally implement some platform specific logic in component.
import { Capacitor } from '#capacitor/core';
console.log(Capacitor.isNative);
//this logs "true" when loading the app after clearing app data or loading app for first time
//but logs "false" when reloading the webview using chrome debugger or when closing app and opening again(without clearing data)
In our case the Capacitor.isNative field changes from being true to false after reloading using chrome debugger or closing and opening app again. Is there something extra we have to do to make sure that Capacitor recognizes the App as a native app? Anybody has any idea as to why the Capacitor object changes after we reload the page?
We have tried using other Capacitor APIs for detecting platform like Capacitor.getPlatform() and Capacitor.platform. Both of these change from "android" to "web" after reopening app or reloading the page using chrome debugger.
We have also seen similar behavior when trying to load other Capacitor Plugins wherein the plugin object changes its structure(i.e. presumably the web implementation gets loaded instead of Android specific implementation) after the page is reloaded or app is restarted. Has anybody faced issues similar to this?

How to clear Android app data in Cordova app

I'm using Phonegap Build for my application. I wonder is there any way to clear ALL app data (not just localStorage or cache) in my app? I have some problems with relogin in my app for Android. When I do localStorage.clear(), it seems like Android doesn't clean data. I also tried to clean cache at that moment (using cordova-plugin-cache-clear plugin). But if I clean app data manually (in phone`s settings) it works perfectly. Otherwise I have conflicts when I try to login again, as if Android use some old previous data. Other platforms work ok.
localStorage.clear should do it (I've used it successfully).
Normally I don't use it though, as (obviously) it cleans out everything.
So, for individual credentials, options and such I use localStorage.removeItem.
There's no need to clear the cache. localStorage calls have immediate effect, at least from the app's point of view.
Without seeing the login code it's hard to be more specific.
You can use this plugin to clear App data for Android and iOS apps:
https://github.com/dpa99c/cordova-plugin-clear-data
Another way, is using ionic framework. There is $ionicHistory.clearCache() which will clear app data.
When change the code and run in borwser by
cordova run browser
and haven't any change, then use:
cordova build
and run again:
cordova run browser

Can we dynamically update the reactnative/android application without going to app store?

Can we dynamically/problematically update the reactnative/android application without going to app store etc ?
Yes definitely you can. Hot code push is the technique to dynamically update the app without forcing users to update the app from play store.
Refer this:-
https://github.com/Microsoft/react-native-code-push
Yes, as your react native code is a bundled JavaScript file, this file can be served from anywhere. Although you can set this up yourself, the most popular service is CodePush created by Microsoft
https://github.com/Microsoft/react-native-code-push

Remote Debugging can't be remove from Ionic App after Release on Play Store

I am using Ionic to build hybrid application.I already made my publishing version and upload on Play store. But when I inspect that app after downloaded from playstore it show all the code of that in chrome inspect so this is very big security risk.Anyone have any idea about how to resolve it?
I think the only thing you can do.. is to minfied and obfuscate your js code (and also minified your css)... for the HMTL ..one possibile solution is to put HTML teplates in angularCache (so it give you also performance boost) ..cause it's more difficulty to read... i think tehre are not other options

Categories

Resources