Looks like Apple converts strings incorrectly in UIActivityViewController

Viewed 430

I was trying to figure out why UIActivityViewController sent a slightly converted string to share for Mail and WeChat.

This is my code:

let activityViewController = UIActivityViewController(activityItems: ["http://preprodgo.travelstart.com/search-on-index?version=3&timestamp=2017-09-15_10-31-27-031"], applicationActivities: nil)

self.present(activityViewController, animated: true, completion: nil)

And when shared by Mail, it was shown as:

http://preprodgo.travelstart.com/search-on-index?version=3×tamp=2017-09-15_10-31-27-031

The system version is 10.3.3.

3 Answers

You can try Following

vat urlString = "http://preprodgo.travelstart.com/search-on-index?version=3&timestamp=2017-09-15_10-31-27-031"
urlString = urlString.StringByReplacingOccurencOf(string:"&", with:"&amp")
let activityViewController = UIActivityViewController(activityItems: [urlString], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)

You can can also replace any url Special character with it HTML Name.

Related