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('').then(supported => {
if (supported) {
Linking.openURL('');
} 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.
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./t/name').then(supported => {
if (supported) {
Linking.openURL('https://www.messenger./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.
Share Improve this question edited Jun 14, 2017 at 16:30 waze asked Jun 14, 2017 at 15:28 wazewaze 5271 gold badge9 silver badges20 bronze badges3 Answers
Reset to default 2Linking.canOpenURL('fb-messenger://').then(supported => {
if (!supported) {
console.log('Can\'t handle url: ' + url);
} else {
Linking.openURL("fb-messenger://user-thread/" + "facebook id");
}
}).catch(err => console.log(err)));
iOS
As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist or canOpenURL will always return false.
Set LSApplicationQueriesSchemes => Restart server
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb-messenger</string>
</array>
Android
To support deep linking on Android, refer http://developer.android./training/app-indexing/deep-linking.html#handling-intents
In case you are still wondering this is a straightforward way just to messenger to the existing react native application without any packages
Linking.openURL(http://m.me/<PAGE_NAME>
)
Official Documentation
For those looking for an answer, this library worked for me: https://github./fiber-god/react-native-app-link