Send link in text message on iPhone

I am developing an application in which you need to send a link in a text message. I use MFMessageComposeViewControllerif iPhone has tried the HTML string, but it doesn’t work. I am using the code:

-(IBAction)sendToSMS:(id)sender
{
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];

    //  NSArray *arr=[[NSArray alloc] initWithObjects:phoneNumber,nil];
    //  [controller setRecipients:[arr objectAtIndex:0]];

    NSLog(@"received:- %@",controller.recipients);
    controller.messageComposeDelegate = self;
    controller.body =@"<html><body><font color=#FFFFFF>Hello,<br><a href=\"http://www.yahoo.com\">click</a>---here to go to Yahoo!</font></body></html>";


    if([MFMessageComposeViewController canSendText])
    {   
        [self presentModalViewController:controller animated:YES];
    }
}
+5
source share
2 answers

SMS does not support HTML or URLs, just text.

All you can do is simply add the URL of the message and then connect to the Message application to find out the URL and allow the user to click on it.

+22
source

Just do something like this:

controller.body =@"Hello, here is a link to Yahoo!\nhttp://www.yahoo.com";

If the receiving phone supports URLs (most of them these days), it will automatically make it valid (touch, clickable, selectable, or whatever)

+3
source

All Articles