当我尝试从设备发送邮件时,发生了奇怪的行为。
我已在应用程序中使用 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];
关于iOS - 通过邮件发送 URL 在模拟器和设备中显示不同的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20785303/