I want to have a feature in my app where the user can send an email to a friend with the iTunes URL to my application. How is it possible?
Thanks.
Rather than the long and confusing urls that you usually see, you can create App Store links that are much simpler and more logical. The iTunes Store has a hidden URL format that’s much more logical. Depending on what you’re linking to, you just need to build a URL in one of these formats:
Just include a url of this format in the body of the email you create.
(Note that spaces might cause problems, but I found that omitting them entirely worked for me - http://itunes.com/app/FrootGroove redirects to the app called "Froot Groove".)
(Also note that if this doesn't work for you, the iTunes link maker is here)
Your code will be something like this (extracted from mine, anonymised and not tested)
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]?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
You can do better things in iPhone 3.0, but I can't talk about those yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With