Search code examples
javascriptreact-nativedeep-linking

React-Native Link app to Facebook Messenger


I know I can deep link maps for example, I used it and it works fine. But how about FB Messenger? I have a button, that when user clicks I want it to open Messenger with a conversation with someone. How can I do it? I tried directly linking but it doesn't work.

  openMessenger() {
    Linking.canOpenURL('https://www.messenger.com/t/name').then(supported => {
        if (supported) {
            Linking.openURL('https://www.messenger.com/t/name');
        } else {
            console.log('erro');
        }
    }).catch(err => console.error('An error occurred', err));
  }

also tried fb-messenger://user-thread/{user-id} and still didn't work.

btw, is there any way to ask the user which app he wants to open with? In the case of the maps, when I click the button it opens on Apple Maps on iOS, but I want it to ask which app to open instead, as I don't use Apple Maps for example.


Solution

  • For those looking for an answer, this library worked for me: https://github.com/fiber-god/react-native-app-link