Search code examples
react-nativereact-native-ios

how to open one app from another app react-native android.?


I am trying React-Native-Linking and react-native-deep-linking but doesnt work.

The following code run successfully only For Skype but if you open another App it doesn't work.

const checkapp = () => {
  let url = "skype://app";
  Linking.openURL(url).catch(err => {
    if (err.code === "EUNSPECIFIED") {
      if (Platform.OS === "android") {
        AppInstalledChecker.isAppInstalled("skype").then(isInstalled => {
          if (isInstalled) {
            Linking.openURL("url");
          } else {
            console.log("is installed false");
            Linking.openURL(
              "https://play.google.com/store/apps/details?id=com.skype.raider&hl=en"
            ).catch(err => {
              console.log(err);
            });
          }
        });
      }
    } else {
      console.log("Platform Is Ios");
    }
  });
};

If any solution then give me.


Solution

  • 100% working for open all app from another app using react-native-send-intent.

    React Native Android module to use Android's Intent actions for opening third party apps.

    Installation npm install react-native-send-intent --save

    Register Module >= 0.29 (in MainApplication.java) Adding only 2 lines

    import com.burnweb.rnsendintent.RNSendIntentPackage;  // <--- import in MainApllication.java
    
    public class MainApplication extends Application implements ReactApplication {
      ......
    
      @Override
      protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNSendIntentPackage()); // <------ add this line to your MainApplication 
      class
      }
    
      ......
    
      }
    

    Example / Open App in your react-native code

     SendIntentAndroid.isAppInstalled('com.medlife.customer').then((isInstalled) => {
                if (isInstalled) {
                    SendIntentAndroid.openApp('com.medlife.customer').then((wasOpened) => {
                    });
                    console.log("is installed true");
                }
                else {
                    Linking.openURL('https://play.google.com/store/apps/details?id=com.medlife.customer&hl=en').catch(err => {
                        console.log(err)
                    })
                }
            });
    

    I am opening 3rd party Medlife app from my app if you have need to open another app then only change pacakage name in SendIntentAndroid.openApp('com.medlife.customer')

    react-native-send-intent git hub example here