Flutter url_launcher open Facebook link inside app(Facebook) installed but in IOS it just open facebook and not the link
My working function:
void _launchSocial(String url, String fallbackUrl) async { // Don't use canLaunch because of fbProtocolUrl (fb://) try { bool launched = await launch(url, forceSafariVC: false, forceWebView: false); if (!launched) { await launch(fallbackUrl, forceSafariVC: false, forceWebView: false); } } catch (e) { await launch(fallbackUrl, forceSafariVC: false, forceWebView: false); }}
Then in onPressed or onTab:
_launchSocial('fb://profile/408834569303957', 'https://www.facebook.com/dorockxl')
Don't forget to add fbYOURPAGEID to CFBundleURLSchemes array in Info.plist:
Note: You can use https://lookup-id.com to find your page's id
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb408834569303957</string> </array> </dict></array>
Btw you can use this method for Twitter and Instagram without an additional setting. Url is enough to open these native apps:
_launchSocial('https://www.instagram.com/YOURNAME/', '')
_launchSocial('https://twitter.com/YOURNAME', '')