我希望我的应用程序中有一项功能,用户可以使用我的应用程序的 iTunes URL 向朋友发送电子邮件。这怎么可能?
Thanks.
您可以创建更简单、更合乎逻辑的 App Store 链接,而不是通常看到的又长又混乱的 URL。 iTunes Store 有一个更符合逻辑的隐藏 URL 格式。根据您要链接的内容,您只需采用以下格式之一构建 URL:
- 艺术家姓名或 App Store 开发者姓名:http://itunes.com/Artist_Or_Developer_Name http://itunes.com/Artist_Or_Developer_Name
- 专辑名称:http://itunes.com/Artist_Name/Album_Name http://itunes.com/Artist_Name/Album_Name
- Apps: http://itunes.com/app/App_Name http://itunes.com/app/App_Name
- Movies: http://itunes.com/movie/Movie_Title http://itunes.com/movie/Movie_Title
- TV: http://itunes.com/tv/Show_Title http://itunes.com/tv/Show_Title
只需在您创建的电子邮件正文中包含此格式的 URL 即可。
(请注意,空格可能会导致问题,但我发现省略它们完全对我有用 -http://itunes.com/app/FrootGroove http://itunes.com/app/FrootGroove重定向到名为“Froot Groove”的应用程序。)
(另请注意,如果这对您不起作用,则 iTunes 链接创建器是here http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsLinkMaker)
你的代码将是这样的(从我的代码中提取,匿名且未经测试)
NSString* body = [NSString stringWithFormat:@"Get my app here - %@.\n",myUrl];
#if __IPHONE_OS_VERSION_MIN_REQUIRED <= __IPHONE_2_2
[NSThread sleepForTimeInterval:1.0];
NSString* crlfBody = [body stringByReplacingOccurrencesOfString:@"\n" withString:@"\r\n"];
NSString* escapedBody = [(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)crlfBody, NULL, CFSTR("?=&+"), kCFStringEncodingUTF8) autorelease];
NSString *mailtoPrefix = [@"mailto:[email protected] /cdn-cgi/l/email-protection?subject=Get my app&body=" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// Finally, combine to create the fully escaped URL string
NSString *mailtoStr = [mailtoPrefix stringByAppendingString:escapedBody];
// And let the application open the merged URL
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailtoStr]];
#endif
你可以在 iPhone 3.0 中做更好的事情,但我还不能谈论这些。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)