【问题标题】:How to open URL with scheme intent:// on react native如何在本机反应中使用方案意图打开 URL://
【发布时间】:2020-10-14 02:32:50
【问题描述】:

我有一个带有 webview 的 react 原生移动应用。在 web 视图中,我添加了 facebook messenger 聊天插件,这样我的用户可以在需要帮助时轻松联系我们。

如果您通过移动浏览器运行该网站,它就可以工作。它会将您重定向到官方信使。

但是当你以某种方式通过 react native webview 运行它时,它会显示 No activity found to handle Intent

这是我如何处理意图打开的代码

onShouldStartLoadWithRequest={(request) => {
    let url = request.url   

    if(url.startsWith('intent:')){
          Linking.openURL(url).catch(er => {
              console.log(er)
              alert("Failed to open URL")
          });

          return false
    }else{
        return true
    }   
}}

这将是控制台日志

[错误:无法打开 URL 'intent://user/107571147455693/?intent_trigger=mme&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata=%7B%22referer_uri%22%3A%22https%3A%5C%2F%5C%2Ffusiontechph.com%5C%2Ff9fe1863270a2%22% #Intent;scheme=fb-messenger;package=com.facebook.orca;end': 未找到处理 Intent { act=android.intent.action.VIEW 的 Activity dat=intent://user/107571147455693/?intent_trigger=mme&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata={"referer_uri":"https://fusiontechph.com/f9fe1863270a2"} flg=0x10000000 }]

【问题讨论】:

    标签: react-native react-native-android facebook-javascript-sdk


    【解决方案1】:

    我有一个对我有用的解决方法。 Facebook Messenger 提供指向您的 Facebook 页面消息的链接。所以你可以直接打开那个链接而不使用facebook的intent scheme这里是最终代码

    onShouldStartLoadWithRequest={(request) => {
        let url = request.url   
                            
        if(url.startsWith('intent:')){
              Linking.openURL('https://m.me/mluc.jsites').catch(e=>{                             
              console.log(e) })
              return false
        }else{
              return true
        }   
    }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      • 2017-08-30
      • 2020-09-09
      • 2023-03-05
      相关资源
      最近更新 更多