6

I want to open New React native App by clicking on Button in which I have used

Linking Concepts in React native

React native Code : Test is the name of the Other App

Linking.openURL('Test://app');

Also following URL for adding Intent in the android.manifest.xml file Andriod Intent

Code : Android.manifestfile.xml

  <activity
        android:name=".MainActivity"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
          <intent-filter>
              <action android:name="android.intent.action.VIEW" />
              <category android:name="com.Test" />
              <category android:name="android.intent.category.BROWSABLE" />
              <data android:scheme="Test" android:host="app" />
          </intent-filter>
      </activity>

How can I resolve the issue?

12
  • I think good is fine . Did you make a build after implement this code . Commented Aug 10, 2018 at 10:07
  • Yes i have done the build but It gives me error (no activity found to handle intent act=android.intent.action.view in react native) Commented Aug 10, 2018 at 10:08
  • I Hope you have react-native apps. from A app you want to open B app. right In a app use this code Linking.openURL('Test://app'); and in B app change Code : Android.manifestfile.xml file. right Please clear .. is i am getting right ? Commented Aug 10, 2018 at 10:13
  • I am doing both the thing in the App A only Commented Aug 10, 2018 at 10:17
  • Why ? you want to open same application on itself click ? Commented Aug 10, 2018 at 10:20

3 Answers 3

6

Add this code in your AndroidManifest.xml file parallel to current intent filter

 <intent-filter android:label="@string/app_name">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "example://gizmos” -->
        <data android:scheme="app"
              android:host="testApp" />
    </intent-filter> 

and run this command React-native run-android

Add below code to your react-native file.

<Button title="Click me" onPress={ ()=>{ Linking.openURL('app://testApp')}} />

for save the time . You can to both code in same application and same application will be open on button press

i just try this code and its working for me let me know if still facing issue (Y)

Sign up to request clarification or add additional context in comments.

8 Comments

Sorry for late replying Anil. Nope its not working, I have applied above code simultaneously. When i clicked on buttoin its reflect and come back to the same place. ( like swipe to the right and same activity has open after that)...
I have done above code in App B androidmanifesfile.xml in which android:host name would be same as my app folder name (testAppA) and now clicking from testAppA but it won't redirect to that ( testAppB ) Please help click is working but it won't open new react native application .
If i am using this way of linking URL (Linking.openURL('testAppA://app')) it gives me error for not handling View intent
can you show me the code of App B androidmanifesfile.xml and link code of a file please
Code : folder name (AppFighter) i have written this code on ChrisApp manifest file. <intent-filter android:label="@string/app_name"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="app" android:host="appfighter" /> </intent-filter> Link to open Chris App (<Button title="Click me" onPress={ ()=>{ Linking.openURL('app://appfighter')}} />)
|
0

You can open the external application by using following code

Linking.canOpenURL("fb://app").then(supported => {
  if (supported) {
    Linking.openURL("fb://app");
  } else {
    alert('sorry invalid url')
  }
});

1 Comment

it's doesn't work with Google Maps App other apps it's work very well, any idea?
-1
<Button title="Click me" onPress={ ()=>{ Linking.openURL('https://google.com')}} />

Here is the link you can check : https://snack.expo.io/rJm_YkqyW

1 Comment

This link is useful for browser URL, I want to open another App ( React Native) by clicking on the button

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.