Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
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

@emclab

Description

@emclab

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

  1. Create react native app
  2. 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.
  3. 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

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions