I'm trying to send via MFMailComposeViewController a custom url scheme so that the receipient could tap on the embedded link and open my application on his iphone. So far the receipient gets an email but nothing happens when he taps on the LINK. here is the code:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self; // <- very important step if you want feedbacks on what the user did with your email sheet
[picker setSubject:@"Incoming task"];
// Fill out the email body text
NSString * types = @"";
for(NSString *type in task.location_types){
types = [types stringByAppendingFormat:@"%@|",type];
}
if(types.length > 1){
types = [types substringToIndex:types.length - 1];
}
NSString *desc = [task.description stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *link = [NSString stringWithFormat:@"helpy://?taskid=%d&desc=%@&types=%@\"",task.TaskId,desc,types];
NSString *emailBody = [NSString stringWithFormat:@"<a href=\"#\" onclick=\"doSomething();\">TAP HERE</a><script type=\"text/javascript\" charset=\"utf-8\">function doSomething() { window.location = \"%@\;return false;}</script>",link];
[picker setMessageBody:emailBody isHTML:YES];
picker.navigationBar.barStyle = UIBarStyleBlack;
[controller presentModalViewController:picker animated:YES];
[picker release];
helpy://?taskid=..... is my custom registered URL Scheme and if I type it from the address bar of the browser it opens up my application on the iPhone. For some reason when this link is embedded into email, tapping it does not do anything. Any help? thanks