简体   繁体   English

Expo React-Native:深层链接在 android 上不起作用

[英]Expo React-Native: Deep linking is not working on android

Deep linking is not working on android when the app is on background or foreground state, but if it's closed it works perfectly fine.当应用程序在后台或前台 state 时,深度链接在 android 上不起作用,但如果它关闭,它工作得很好。 Only in android but in iOS it works both even if it's in background or closed app state.仅在 android 中,但在 iOS 中,即使它在后台或关闭的应用程序 state 中,它都可以工作。

I have these methods, but it doesn't work on android when it's on background or foreground我有这些方法,但它在后台或前台时不适用于 android

1. Linking.addEventListener('url', callback)
2. Linking.getInitialURL -- it returns a Promise that resolves to the url, if there is one.

最后我想通了, Linking.addEventListener('url', callback)返回和事件,要获取 url 它应该是event.url ,我之前做的是Linking.addEventListener('url',(url) => setLink(url))必须是Linking.addEventListener('url',({ url }) => setLink(url))

 Linking.canOpenURL(ValidateRedirectionData.responseDto.redirectUrl).then(
    (supported) => {
      console.log(supported, "sup--------------");

      Linking.openURL(ValidateRedirectionData.responseDto.redirectUrl);

      console.log("deeplinking2------------------------");
    }
  );

try like this像这样尝试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM