2016-06-06 2 views
2

링크 라이브러리를 사용하여 반응 네이티브로 IOS에서 들어오는 링크를 수신하고 처리 할 수 ​​있지만 URL에 이벤트 리스너를 추가하는 기능은 IOS입니다. 플랫폼 별. 안드로이드에서 내 애플 리케이션에 들어오는 링크를 듣고 자바 스크립트 측면에서 처리하는 다른 방법이 있습니까?React-Native로 안드로이드에서 들어오는 링크 듣기

+0

[반작용 기본으로 딥 링크 (http://ihor.burlachenko.com/deep-linking-with-react-native/) –

답변

5

방금 ​​작동했습니다. these instructions을 따라하면됩니다. 기본적으로

VIEW 행동의 DEFAULTBROWSABLE 범주를 포함하여 android/app/src/main/AndroidManifest.xml의 기존하에 <intent-filter>를 추가하고, 적어도 <data>.

그런 다음 APK (react-native run-android)를 다시 작성하고 다시 설치하면됩니다. <data> 태그와 일치하는 링크가 이제 앱에서 열립니다!

이제 기본 JavaScript 클래스의 componentDidMount()에서 Linking.getInitialURL()으로이 URL을 잡으세요. 매니페스트

예 :

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="net.yourapp" 
    android:versionCode="1" 
    android:versionName="0.1"> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> 

    <uses-sdk 
    android:minSdkVersion="16" 
    android:targetSdkVersion="22" /> 

    <application 
    android:name=".MainApplication" 
    android:allowBackup="true" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:icon="@mipmap/ic_launcher" 
    android:theme="@style/AppTheme"> 

    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" 
     android:configChanges="keyboard|keyboardHidden|screenSize"> 
     <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

     <!-- HERE: --> 
     <intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
     <data android:scheme="https" 
      android:host="yoursite.net" /> 
     <data android:scheme="https" 
      android:host="yoursite.net" /> 
     <data android:scheme="https" 
      android:host="yoursite" /> 
     <data android:scheme="customscheme" 
      android:host="yourpath" /> 
     </intent-filter> 

    </activity> 
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> 
    </application> 

</manifest> 
관련 문제