iOS - 通过邮件发送 URL 在模拟器和设备中显示不同的行为

标签 ios objective-c email smtp

当我尝试从设备发送邮件时,发生了奇怪的行为。

我已在应用程序中使用 SMTP 从后台发送邮件,并且必须在应用程序中发送用户的当前位置 URL。

现在,当我从模拟器发送它时,它几乎可以正常工作,并且我得到了这个 url -

https://maps.google.com/maps?f=q&q=0.000000,0.000000

但是,当我从设备发送它时,它会发送这样的网址 -

https://maps.google.com/maps?f=q&q ".719793,75.877068

我用来制作url的代码是

-(NSString*)LocationLinkTosentInMail
{
    CLLocationCoordinate2D coordinate = [self getLocation];
    NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
    NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];

    NSLog(@"*dLatitude : %@", latitude);
    NSLog(@"*dLongitude : %@",longitude);


    NSString *currentLocationURL = [NSString stringWithFormat:@"https://maps.google.com/maps?f=q&q=%@,%@",latitude,longitude];

    return currentLocationURL;

}


 NSURL *locationURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[self LocationLinkTosentInMail]]];

在SMTP邮件功能中,我使用这段代码来制作字典

NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys:
                                         @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey,
                                         [NSString stringWithFormat:@"My Location is: %@",locationURL], kSKPSMTPPartMessageKey,
        @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey,
        nil];

如果代码需要任何更改,有人可以建议我吗?

为什么模拟器和设备在发送此 URL 时表现出不同的行为?

最佳答案

在 iOS 中使用 HTML 标签并在邮件正文中启用 HTML

[emailDialog setMessageBody:mailBody isHTML:YES];

Check this page for href tag!

关于iOS - 通过邮件发送 URL 在模拟器和设备中显示不同的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20785303/

相关文章:

ios - NSURLSession 后台传输不工作

ios - 警告 : I could not find the column named 'rowid'

ios - Objective-c NSArray 在线测试

iphone - 启动图像 - iPhone 应用程序

Android:如何在 Android 中访问电子邮件地址

javascript - 通过邮件发送 jQuery 变量

javascript - 使用 GmailApp.SendMail 时显示名称导致无效电子邮件错误

iOS UIWebView 页面加载可观察性

ios - 按键值查询 Firebase 数据库

iphone - 当同步访问对象时,是什么导致对象 [0] 处出现 nil 对象?