Repository navigation
[url_launcher] README instructions for SMS are incorrect #156281
Description
Activity
- changed the title
[-]SMS body containing "&" doesn't work as expected on Android[/-][+][url_launcher] SMS body containing "&" doesn't work as expected on Android[/+]on Oct 5, 2024 I somehow missed in reviewing flutter-team-archive/plugins#6042 that it was adding entirely new instructions for SMS. Those instructions are incorrect, and will double-encode the body; I'll update the README to fix that.
The correct version would look like the
mailtoexample in the README, using thequery: encodeQueryParameters(...)construction.- changed the title
[-][url_launcher] SMS body containing "&" doesn't work as expected on Android[/-][+][url_launcher] README instructions for SMS are incorrect[/+]on Oct 5, 2024 - addedp: url_launcherPlugin to launch external applicationsPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.P1High-priority issues at the top of the work listHigh-priority issues at the top of the work list
on Oct 5, 2024 - addedteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
on Oct 5, 2024 Hi @stuartmorgan, thank you for the quick response but I found the issue still exists with
query: encodeQueryParameters(...)approach.String? encodeQueryParameters(Map<String, String> params) { return params.entries .map((MapEntry<String, String> e) => '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}') .join('&'); } final uri = Uri( scheme: 'sms', query: encodeQueryParameters(<String, String>{ 'body': 'Hello & World', }), );
I tried this code, but the message body is shown as "Hello " instead of "Hello & World". By the point space behind "Hello" remains, it looks like everything behind "&" is truncated. Could you please be kind to let me know if I'm still misunderstanding the instruction?
Plus, I found the message "Hello & World" works well on Android native code if I give it as extra of intent (
putExtra("sms_body", message). It looks like that url_launcher sets everyting as intent's data(setData(Uri.parse(url))), could that be related somehow?I tried this code, but the message body is shown as "Hello " instead of "Hello & World". By the point space behind "Hello" remains, it looks like everything behind "&" is truncated. Could you please be kind to let me know if I'm still misunderstanding the instruction?
That new code is doing correct escaping. If the receiving phone app mis-parses the body of correctly encoded URLs, you'd need to file an issue with the developer of that app;
url_launchercannot control what happens after the URL is passed to the OS.It looks like that url_launcher sets everyting as intent's data
url_launcheris not intended as a general intent library, it's for simple URL handoff.I tried it with basic sms app of Samsung Galaxy S22. Then it must be another Samsung device issue I guess...
I will try to find some other solution for it. Thank you so much for the kind explanations.
- added a commit that references this issue
on Oct 7, 2024 - added a commit that references this issue
on Oct 8, 2024 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Oct 22, 2024 - added a commit that references this issue
on Jun 10, 2026 - added a commit that references this issue
on Jun 19, 2026
What package does this bug report belong to?
url_launcher
What target platforms are you seeing this bug on?
Android
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
Steps to reproduce
Uriwith "sms" scheme, set message to any string that contains character "&".launchUrl(uri, mode: LaunchMode.externalApplication)Expected results
The message given to Uri properly shows on sms body field.
Actual results
The message is not shown as it's given on the
Uri.If the original message was "Hello & World", depending on how I created
Uri, it appears either "Hello%20%26%20World" or "Hello ".Code sample
Code sample
Screenshots or Videos
No response
Logs
No response
Flutter Doctor output
Doctor output