social_share icon indicating copy to clipboard operation
social_share copied to clipboard

SocialShare.shareSms does not work on iOS

Open mihail-varbanov opened this issue 1 year ago • 6 comments

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.

mihail-varbanov avatar Nov 10 '23 09:11 mihail-varbanov

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

drxddy avatar Dec 28 '23 14:12 drxddy

@dhikshithrm how exactly does your share method look like ?

DieGlueckswurst avatar Sep 04 '24 11:09 DieGlueckswurst

  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.

drxddy avatar Sep 04 '24 11:09 drxddy

@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'

DieGlueckswurst avatar Sep 04 '24 12:09 DieGlueckswurst

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..?

https://github.com/ShekarMudaliyar/social_share/blob/073e17446a8604e2d11dd7c5e271359cd75aa56a/android/src/main/kotlin/com/shekarmudaliyar/social_share/SocialSharePlugin.kt#L181-L194

drxddy avatar Sep 04 '24 12:09 drxddy

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

btw, thanks for the help! highly appreciated

DieGlueckswurst avatar Sep 04 '24 13:09 DieGlueckswurst