[英]React Native Firebase dynamic links send improperly via iMessage
[英]Configuring Firebase Dynamic Links with React Navigation
我正在努力使用 React Navigation 配置 Firebase 動態鏈接。 動態鏈接成功觸發應用程序。 但是,它沒有導航到正確的路線(屏幕)。我正在研究 Android,但還沒有開始(對我來說)更困難的 iOS 配置。 我確定我的一個(或多個)配置選項有誤。 我將非常感謝您付出的努力和時間來提供幫助。
以下工作並導航到正確的路線:
adb shell am start -W -a android.intent.action.VIEW -d casualjob://InvitedEmployee com.casualjob
。
以下啟動應用程序,但未導航到正確的路線:
npx uri-scheme open "https://casualjobsyd.page.link/app?link=https%3A%2F%2Fbuildwebsitepro.com.au%2Fcasualjob%2FInvitedEmployee" --android
。
鏈接預覽https://casualjobsyd.page.link/app?d=1
返回動態鏈接樹成功。 以下命令返回正確的 json: https://casualjobsyd.page.link/.well-known/assetlinks.json
Firebase 控制台配置:
https://casualjobsyd.page.link
https://casualjobsyd.page.link/app
https://buildwebsitepro.com.au/casualjob
AndroidManifest.xml
...
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true"
>
<intent-filter android:autoVerify="true">
<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="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="casualjob"/>
</intent-filter>
<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="http" android:host="casualjobsyd.page.link/app"/>
<data android:scheme="https" android:host="casualjobsyd.page.link/app"/>
</intent-filter>
</activity>
...
使用以下代碼生成動態鏈接:
const link = await dynamicLinks().buildLink({
link: "https://buildwebsitepro.com.au/casualjob/",
domainUriPrefix: "https://casualjobsyd.page.link/app",
});
const linkSentToUser = link + "InvitedEmployee";
// result of the above is: "https://casualjobsyd.page.link/app?link=https%3A%2F%2Fbuildwebsitepro.com.au%2Fcasualjob%2FInvitedEmployee"
React Navigation 動態鏈接配置:
const linking = {
prefixes: ["casualjob://", "https://casualjobsyd.page.link/app", ],
config: config,
async getInitialURL() {
const { isAvailable } = utils().playServicesAvailability;
if (isAvailable) {
const initialLink = await dynamicLinks().getInitialLink();
if (initialLink) {
return initialLink.url;
}
}
const url = await Linking.getInitialURL();
return url;
},
subscribe(listener) {
const unsubscribeFirebase = dynamicLinks().onLink(({ url }) => {
listener(url);
});
const linkingSubscription = Linking.addEventListener("url", ({ url }) => {
listener(url);
});
return () => {
unsubscribeFirebase();
linkingSubscription.remove();
};
},
};
我想到了。 最重要的變化是需要將每個深層鏈接添加到 Firebase 控制台。 對於上面的示例,我必須更改以下內容。
在 Firebase 控制台上定義的Deep Link
是: https://buildwebsitepro.com.au/casualjob
在 Firebase 控制台上定義的Deep Link
應該是: https://buildwebsitepro.com.au/casualjob/InvitedEmployee
還需要應用其他更改。
const linking = {
// The 2nd element below should be changed to look like the following.
prefixes: ["casualjob://", "https://casualjobsyd.page.link/app", ],
// ...
}
我了解到我的 Androidmanifest.xml 是錯誤的。 以下是文檔推薦的,雖然它似乎沒有必要??
<!-- Note that the android:host must be set to the domain of "your deep link," and NOT the "Dynamic Links" domain -->
<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="buildwebsitepro.com.au" android:pathPrefix="/casualjob/" />
</intent-filter>
<!-- android:autoVerify="true" is required below -->
<!-- Note that the android:host must be set to your "Dynamic Links" domain, and not the domain of "your deep link." -->
<intent-filter android:autoVerify="true">
<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="casualjobsyd.page.link/app"/>
<data android:scheme="http" android:host="casualjobsyd.page.link/app"/>
</intent-filter>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.