Reputation: 13713
Trying to share a NSAttributedString
string (contains embedded links) via SMS by using UIActivityViewController
:
let activityViewController = UIActivityViewController(activityItems: [linkToShare], applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
linkToShare
is of type NSMutableAttributedString
Unfortunately the text is shared but without the embedded links (and the words for the links are not highlighted). When sharing via the Mail activity the text appears as expected (worded links are highlighted and links are working).
Does the SMS activity works with attributed string or am I missing something here?
Upvotes: 1
Views: 1091
Reputation: 1625
The SMS activity does work with NSAttributedString
in a sense that it compiles and does not crash. But as for the Mail activity, the attributed string has to be converted into a format suitable with the protocol ultimately used to transfer the message.
For the Mail activity, the attributed string can be converted into html which will keep the format of your string.
For SMS, plain text is the only possibility so that's why the attributes you set are ignored.
That said, some SMS clients will auto-detect links as the Message app does on iOS. In the end, the formatting of an SMS message depends more on the receiving client than on the sender.
Upvotes: 1