[英]Firebase dynamic links are null after new install, but work well when installed
安装应用程序后,深度链接配置适用于 iOS 和 Android。 域https://friends.unblnd.com/dynamic的配置文件似乎没问题。
但安装后无法识别深层链接。
所以监听器工作得很好,但是从后台开始时得到初始的 url 不是。
//安装应用程序时,我们会得到预期的行为:
I/ReactNativeJS: 'FIREBASE LISTENING:', { utmParameters:
{ utm_source: 'firebase',
utm_medium: 'dynamic_link',
utm_campaign: 'Online Cooking | UNBLND' },
minimumAppVersion: null,
url: 'https://unblnd.com/invite/group/eyJpdiI6IkNyMSsxTnJRWHJyQys3ZWZZd0R5Tnc9PSIsInZhbHVlIjoiRlFaQ2o3R0F0cnRpLzFvYzZ3WC9tQT09IiwibWFjIjoiOWFhZmIzZjk2MjM1MGQ5YTU5Y2M5YjBmOTIwNTdjODZkMzE3ZGY4ZTMyOTZmOTNhY2ZhZGM5NGNjNzc1NDEzYiJ9' }
// 当点击Firebase动态链接(friends.unblnd.com/dynamic/aF8A),需要安装应用,安装后找不到深层链接:
I/ReactNativeJS: 'FIREBASE URL:', null
深度链接在 React Navigation v5 中配置。 添加了用于获取初始 url 的自定义 function 并订阅 function,以下const linking
添加为属性<NavigationContainer linking={linking}...>
const linking = {
prefixes: [
'https://friends.unblnd.com/dynamic/',
...
],
config: deepLinksConf,
// Custom function to get the URL which was used to open the app
async getInitialURL() {
// First, you may want to do the default deep link handling
// Check if app was opened from a deep link
const url = await Linking.getInitialURL();
console.log('FOUND URL:', url);
if (url != null) {
return url;
}
// Next, you would need to get the initial URL from your third-party integration
// It depends on the third-party SDK you use
const link = await dynamicLinks().getInitialLink();
for (var i = 0; i < 20; i++) {
setTimeout(async function () {
console.log('FIREBASE:', i, await dynamicLinks().getInitialLink());
}, 500 * i);
}
console.log('FIREBASE URL:', url);
return link.url;
},
// Custom function to subscribe to incoming links
subscribe(listener) {
// First, you may want to do the default deep link handling
const onReceiveURL = ({url}) => {
console.log(url);
... handle url
listener(url);
};
// Listen to incoming links from deep linking
Linking.addEventListener('url', onReceiveURL);
const unsubscribeToDynamicLinks = dynamicLinks().onLink((link) => {
console.log('FIREBASE LISTENING:', link);
onReceiveURL(link);
});
return () => {
// Clean up the event listeners
unsubscribeToDynamicLinks();
Linking.removeEventListener('url', onReceiveURL);
};
},
};
- 配置:Firebase 动态链接
在您的 Android 应用程序 [APP] 中打开深层链接
如果您的应用尚未安装,请将用户引导至您的应用的 Google Play 页面
- 反应原生:信息
System:
OS: macOS 11.5.2
CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 43.73 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: Not Found
npm: 6.14.15 - ~/htdocs/unblnd_app/node_modules/.bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2
System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7486908
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_265 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
@react-native-firebase/analytics: "^12.8.0",
@react-native-firebase/app: "^12.8.0",
@react-native-firebase/dynamic-links: "^12.8.0",
@react-navigation/native: "^5.9.4",
@react-navigation/stack: "^5.14.5",
如何使其按预期工作? 现在,它与内部 url 方案具有相同的行为......也许需要尝试 Branch.io?
我们开始使用 branch.io 并且效果很好: npm package - react native branch
在查找 firebase 文档和其他 stackoverflow 选项后,我们创建了一段代码来帮助解决此问题。
您需要在 info.plist 文件中添加“FirebaseDynamicLinksCustomDomains”参数。
动态 URL: https://yourapp.page.link/?link=https://yourapp.com/test=12345&isi=14602xxxxx&ibi=com.xxxx.yourapp
info.plist 文件中的重要参数:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://yourapp.com</string>
<string>https://yourapp.com/link</string>
</array>
如果您的生产关键应用程序存在此问题,请随时向我咨询。 在https://khushalbhalsod.nl 联系我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.