我正在尝试通过 MFMailComposeViewController 发送自定义 url 方案,以便收件人可以点击嵌入式链接并在他的 iphone 上打开我的应用程序。到目前为止,收件人收到了一封电子邮件,但当他点击 LINK 时没有任何反应。这是代码:
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=..... 是我自定义注册的 URL 方案,如果我从浏览器的地址栏中键入它,它会在 iPhone 上打开我的应用程序。出于某种原因,当这个链接嵌入到电子邮件中时,点击它不会做任何事情。有什么帮助吗?谢谢