Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SocialShare.shareSms does not work on iOS #146

Open
mihail-varbanov opened this issue Nov 10, 2023 · 6 comments
Open

SocialShare.shareSms does not work on iOS #146

mihail-varbanov opened this issue Nov 10, 2023 · 6 comments

Comments

@mihail-varbanov
Copy link

Invoke on iOS platform:
SocialShare.shareSms('Rev Spring 2024 Ready-to-Wear\n', url: 'https://www.vogue.com/fashion-shows/spring-2024-ready-to-wear/rev/slideshow/collection', trailingText: '')

Result: Nothing happens

Reason:
The following line uses wrong SMS URL format that is not supported in iOS:
NSString *urlSchemeSms = [NSString stringWithFormat:@"sms:?&body=%@",msg];

This should be without the question mark:
NSString *urlSchemeSms = [NSString stringWithFormat:@"sms:&body=%@",msg];

Also, urlLink parameter is not acknowledged anywhere.

@drxddy
Copy link

drxddy commented Dec 28, 2023

for now, i found a work around by interpolating the URL into the SMS, and it's working, iMessage will handle the URL parsing for thumbnails

@DieGlueckswurst
Copy link

@dhikshithrm how exactly does your share method look like ?

@drxddy
Copy link

drxddy commented Sep 4, 2024

  Future<void> shareOnSms(String dynamicLink) async {
    final String text =
        """I'm excited to start this new habit "${widget.name}" on the folksable app,
where i plan to be accountable with friends and family by posting regular 
progress photos, and maintain a streak.

It would motivate me alot if you join me on this journey, and keep me accountable.
Here is the link to join: $dynamicLink
""";
    await SocialShare.shareSms(text);
  }

This is based on observation that most sms apps do parse out the link to make it clickable with in the text itself so this will work like any text message with a link.

@DieGlueckswurst
Copy link

DieGlueckswurst commented Sep 4, 2024

@dhikshithrm
did you modify anything inside the package? Because for me, still nothing happens and I get error as a response.

And when adding a url , the app crashes with:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1f5b23f98'

@drxddy
Copy link

drxddy commented Sep 4, 2024

No, I hadn't modified the package inside, just used the text, and removed url param, because that was crashing my app as well, but otherwise the text is working fine.

just checked the android platform code, if you are getting error coming from the catch block of ActivityNotFoundException, for me the SMS activity is opening fine on android and ios, which platform is it not working for you..?

} else if (call.method == "shareSms") {
//shares content on sms
val content: String? = call.argument("message")
val intent = Intent(Intent.ACTION_SENDTO)
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.type = "vnd.android-dir/mms-sms"
intent.data = Uri.parse("sms:" )
intent.putExtra("sms_body", content)
try {
activity!!.startActivity(intent)
result.success("success")
} catch (ex: ActivityNotFoundException) {
result.success("error")
}

@DieGlueckswurst
Copy link

@dhikshithrm getting the error in iOS... still no idea why. Can't make anything from the logs.

btw, thanks for the help! highly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants