This repository was archived by the owner on May 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This repository was archived by the owner on May 20, 2025. It is now read-only.
How to make code push NOT loaded into stack when react native app is launched #2560
Copy link
Copy link
Closed
Description
This is a question about the loading of the react native code push. The code push module retrieves ANDROIDID and the react native (0.70) app needs to get a user permission before retrieving ANDROIDID. Is there way to load code push into stack AFTER user's permission? I tried to require
react native-code-push after users' permission. However the stack still shows the code push module has been loaded into stack (retrieving ANDROIDID has been called) as soon as the app is launched.
Steps to Reproduce
- Create react native app
- conditionally require react-native-code-push in App.js (instead in index.js as doc says). ex
const codePush = require('react-native-code-push');
in a function and is only executed when the function is called. - Check the stack to see if the code push has been loaded even before the condition is met.
Expected Behavior
What you expected to happen?
Code push is not loaded if the users don't issue permission.
Actual Behavior
What actually happens?
Code push is loaded as soon as the react native app is launched
STACK TRACE AND/OR SCREENSHOTS
[com.microsoft.codepush.react.CodePushNativeModule.<init>(CodePushNativeModule.java:63), //<<==ANDROIDID is retrieved.
com.microsoft.codepush.react.CodePush.createNativeModules(CodePush.java:414),
com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42),
com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42),
com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1456),
com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1427),
com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1338),
com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:136),
com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1108),
java.lang.Thread.run(Thread.java:933)]
Reproducible Demo
- Download https://github.com/microsoft/react-native-code-push/archive/master.zip and unzip. From
Examples
folder runnode create-app.js appName [email protected] [email protected]
command to generate plain CodePushified React Native app. Please see description on top ofcreate-app.js
file content if needed - If you can't reproduce the bug on it, provide us as much info as possible about your project
Environment
- react-native-code-push version: 7.0.x
- react-native version: 0.70
- iOS/Android/Windows version: MacOS 13
- Does this reproduce on a debug build or release build?
- Does this reproduce on a simulator, or only on a physical device?
(The more info the faster we will be able to address it!)
Metadata
Metadata
Assignees
Labels
No labels