How to open “SMS” with boby

Hello everybody
I have error when open sms attack body
This my code:
url NSURL = NSURL.URLWithString (“sms:” + toPhoneNumber + “&body=My Text, xxxx”);
UIApplication.sharedApplication (). OpenURL (url);

How to fix it ?

I resolved my problem with code and run ok

String body = “My text xxx”;
NSCharacterSet characterSet = NSCharacterSet.URLHostAllowedCharacterSet();
body = NSString.alloc().initWithString(body).stringByAddingPercentEncodingWithAllowedCharacters(characterSet);
NSURL url = NSURL.URLWithString(“sms:1234567890&body=” + body);
UIApplication.sharedApplication().openURL(url);

Can also use java.net.URLEncoder.encode(body, 'utf-8') for more platform independency.

2 Likes