Created
September 25, 2021 07:40
-
-
Save akimabs/57e70bd8f5c85e4d60f648fdb64dee5b to your computer and use it in GitHub Desktop.
Integration deep-link with react navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Setup intent di AndroidManifest.xml | |
note: url di sini karna sudah memakai react-native-config jadi tinggal panggil saja seperti | |
@string/Static_url = urlmase.id | |
isikan android:host dengan domain anda | |
dan android:scheme dengan https/http(tergantung domainnya) | |
<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:host="@string/Static_url" android:scheme="https" /> | |
</intent-filter> | |
2. Setup linking buat routing nantinya | |
buka file stack navigator, lalu buat file linking.js/ts | |
dan isi file tersebut dengan kodingan sesuai | |
a. domain deep link | |
b. screen yang dituju | |
c. payload(optional) | |
di case saya link yang dipakai adalah = https://urlmase.id/navigate/login | |
cth: | |
import Config from 'react-native-config'; | |
const config = { | |
screens: { | |
Login: { | |
path: 'navigate/login', | |
}, | |
}, | |
}; | |
const linking = { | |
prefixes: [`${Config.Static_url}`], | |
config, | |
}; | |
export default linking; | |
3. Pasangkan linking dengan stack navigator anda | |
import file yang tadi dibuat, lalu pasangkan di props linking pada <NavigationContainer /> | |
4. Testing | |
paste https://urlmase.id/navigate/login pada telegram/wa/dsb (btw chrome gabisa ya) | |
dan jika berhasil maka akan ada pilihan app anda dan web browser ketika anda klik url tersebut | |
Syudah |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment