flutterdarttextfacebook-messengerviber

Send text to Viber and Facebook Messenger with Flutter


How can I send a text directly to a specific phone number on Viber? or to a specific person on Facebook messenger?

with whatsapp I'm using url_launcher with whatsapp with below code, and it is working fine.

var whatsapp_url = "whatsapp://send?phone=" + whatsapp_number + "&text=hellooo";
try {
await launchUrl(Uri.parse(whatsapp_url));
} catch (e) {
print('could not launch whatsapp');
}

I tried using the same package with Viber using ("viber://chat?number=") and Facebook messenger using ('m.me/username') but both are just opening a web site and not opening the mobile App and not finding the phone number or the messenger chat.

I need to do a similar thing by clicking an IconButton to open a specific chat on Viber and another IconButton to open a specific Facebook messenger chat.


Solution

  • I found a solution in case someone needed - I used the same url_launcher library.

    Then used this code for launching it:

    final Uri app_link_uri = Uri.parse(app_link);
      try {
        await launchUrl(
          app_link_uri,
          mode: LaunchMode.externalApplication,
        );
      } catch (error) {
        print(‘error’ catching: $error);
      }