Search code examples
fluttersmsurl-launcher

Flutter url_launcher send sms not loading number in the imessenger


Hi I am trying to send sms using url_launcher package in an iOS mobile device. The user clicks a button on my app and the url launcher triggers the iMessage and populates the phone number and message to be sent. Following is the code I am using for button click:

final Uri smsLaunchUri =
      Uri(scheme: 'sms', path: '3939393939', queryParameters: <String, String>{
    'body': Uri.encodeComponent('Example Subject & Symbols are allowed!'),
  });
  if (await canLaunchUrl(smsLaunchUri)) {
    
    launchUrl(smsLaunchUri);
  } else {
    throw 'Could not launch';
  }
}

I have following in the info plist file:

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>sms</string>
        <string>tel</string>
    </array>

But once the messenger is launched the 'To:' filed has 'No Name' and loading circle. Also there is no message in the message field. That number is saved in the simulator device with a 'test contact'.

enter image description here


Solution

  • I was having the same problem, but when I ran it on an actually ios device it worked fine. Seems like it has something todo with the simulator.