How to open URL with scheme intent:// on react native

0

I have a react native mobile app with a webview. In the webview I added the facebook messenger chat plugin so my users can easily contact us if they need help.

if you ran the website through a mobile browser it works. It redirects you to the official messenger.

But when you ran it through react native webview somehow it says No activity found to handle Intent

here is my code on how i handle the opening of the 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
    }   
}}

this will console log

[Error: Could not open 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%7D#Intent;scheme=fb-messenger;package=com.facebook.orca;end': No Activity found to handle Intent { act=android.intent.action.VIEW 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
asked on Stack Overflow Oct 14, 2020 by Cardo

1 Answer

0

I have a workaround that worked for me. Facebook messenger provides a link to your facebook page message. So you can just open that link directly without using the intent scheme of facebook here is the final code

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
    }   
}}
answered on Stack Overflow Oct 14, 2020 by Cardo

User contributions licensed under CC BY-SA 3.0