如何在App Store(iTunes)中链接到我的应用程序?

los*_*sit 27 iphone app-store ios

我希望在我的应用程序中有一个功能,用户可以通过iTunes URL向我的应用程序发送电子邮件给朋友.这怎么可能?

谢谢.

Jan*_*les 47

您可以创建更简单,更符合逻辑的App Store链接,而不是您经常看到的长而混乱的URL.iTunes Store有一个隐藏的URL格式,更合乎逻辑.根据您要链接的内容,您只需要使用以下格式之一构建URL:

  1. 艺术家的名字或App Store开发者的名字:http://itunes.com/Artist_Or_Developer_Name
  2. 专辑名称:http://itunes.com/Artist_Name/Album_Name
  3. 应用:http://itunes.com/app/App_Name
  4. 电影:http://itunes.com/movie/Movie_Title
  5. 电视:http://itunes.com/tv/Show_Title

只需在您创建的电子邮件正文中包含此格式的网址即可.

(请注意,空格可能会导致问题,但我发现省略它们完全适合我 - http://itunes.com/app/FrootGroove重定向到名为"Froot Groove"的应用程序.)

(另请注意,如果这对您不起作用,iTunes链接制作者就在这里)

你的代码将是这样的(从我的提取,匿名和未测试)

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:xxx@wibble.com?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
Run Code Online (Sandbox Code Playgroud)

你可以在iPhone 3.0中做得更好,但我还不能谈论那些.

  • 那么OS 3.0中的新东西是什么? (6认同)