ios newbie
ios newbie

Reputation: 65

android: React native open an app from another app?

I am trying to open a another app(https://play.google.com/store/apps/details?id=com.inova.velocity) from my app. But there are all the tutorial just redirecting url to playstore only.(I found a github link(https://github.com/FiberJW/react-native-app-link) and it opens the app for iOS only, but for Android it is redirecting to playstore). Is there is any way to solve this problem?

Linking.canOpenURL('market://details?id=com.inova.velocity')
      .then((canOpen) => {
        if (canOpen) { 
          console.log('open app'); 
          return Linking.openURL('market://details?id=com.inova.velocity')
                 };
        }).catch(err => console.log('An error occurred', err));

Upvotes: 3

Views: 5304

Answers (2)

Manojkanth
Manojkanth

Reputation: 1169

Yes your code is correct. But you have used playstore url, instead of schema url. you have to set the schemaUrl which you can get it from relevant app developer. if there is no schema url set for the that app you can't open it. after you get the SchemaUrl you can use your code. like below.


Linking.canOpenURL(SchemaUrl).then(supported => {
             if (supported) {
               console.log('accepted');
               return Linking.openURL(SchemaUrl);
             } else {
               console.log('an error occured');
             }
           }).catch(
             err => console.log('an error occured');
           );

Upvotes: 2

Karan Harsh Wardhan
Karan Harsh Wardhan

Reputation: 1136

using react-native-send-intent module , you can do
SendIntentAndroid.openApp('packagename').then((wasOpened) => {}); where your package name is whatever application package name you want to open.

for eg SendIntentAndroid.openApp('com.inova.velocity').then((wasOpened) => {});

wasOpened is a Boolean promise telling you whether the app was opened or not

Upvotes: -1

Related Questions