문제

내 앱에 사용자가 내 응용 프로그램에 iTunes URL을 사용하여 친구에게 이메일을 보낼 수있는 기능을 갖고 싶습니다. 그게 어떻게 가능해?

감사.

도움이 되었습니까?

해결책

일반적으로 보는 길고 혼란스러운 URL이 아니라 훨씬 간단하고 논리적 인 앱 스토어 링크를 만들 수 있습니다. iTunes 스토어에는 훨씬 더 논리적 인 숨겨진 URL 형식이 있습니다. 연결하는 내용에 따라 이러한 형식 중 하나에서 URL을 작성하면됩니다.

  1. 아티스트 이름 또는 앱 스토어 개발자 이름 : 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. TV: http://itunes.com/tv/show_title

이 형식의 URL을 작성하는 이메일 본문에 포함하십시오.

(공간이 문제를 일으킬 수 있지만, 나는 그들을 완전히 생략하는 것이 나를 위해 일했다는 것을 알았습니다. 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

iPhone 3.0에서는 더 나은 일을 할 수 있지만 아직 그것에 대해 이야기 할 수는 없습니다.

다른 팁

OS 3.0에서는 MessageUi 프레임 워크를 사용하여 앱을 남기지 않고이 작업을 수행 할 수 있습니다 (Jane의 코드를 3.0 이전 장치의 폴백으로 사용) :

- (void)sendEmail
{
    NSString* body = [NSString stringWithFormat:@"Get my app here - %@.\n",myUrl];

#if __IPHONE_OS_VERSION_MIN_REQUIRED <= __IPHONE_2_2
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil && [mailClass canSendMail])
    {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;
        picker.subject = @"Get my app";
        [picker setToRecipients:[NSArray arrayWithObject:@"xxx@wibble.com"];
        [picker setMessageBody:body isHTML:NO];

        [self presentModalViewController:picker animated:NO];
        [picker release];
    } else {
        [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
}

#pragma mark -
#pragma mark Mail Composer Delegate
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    if (result == MFMailComposeResultFailed) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[error localizedDescription] message:[error localizedFailureReason] delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    [self dismissModalViewControllerAnimated:YES];
}

귀하의 수업은 다음을 채택해야합니다 MFMailComposeViewControllerDelegate 규약. 부착물을 포함하고 신체에 HTML을 사용하는 등을 포함시킬 수 있습니다.

이제 appstore.com/app_name을 사용하여 iTunes에서 앱을 시작할 수 있습니다. 이것은 데스크탑 및 iOS 장치에서 작동합니다. 그러나 이것은 다른 방법만큼 신뢰할 수 없습니다. 여기에서 답변을 참조하십시오 Apple Appstore 용 Vanity URL을 만드는 방법은 무엇입니까?

이 코드 App Store 링크를 자동으로 생성합니다 앱 이름을 기준으로 다른 것이 필요하지 않습니다. 드래그 앤 드롭:

NSCharacterSet *trimSet = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ0123456789"] invertedSet];    
NSArray *trimmedAppname = [[NSString stringWithString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]] componentsSeparatedByCharactersInSet:trimSet];
NSString *appStoreLink = @"http://itunes.com/app/"; 
for (NSString *part in trimmedAppname) appStoreLink = [NSString stringWithFormat:@"%@%@",appStoreLink,part];
NSLog(@"App store URL:%@",appStoreLink);

그것은 당신에게 같은 링크를 제공합니다 http://itunes.com/app/angrybirds

그건 그렇고, ID에 의한 응용 프로그램에 대한 링크는 응용 프로그램을위한 앱 스토어를 방문하고 "친구에게 친구에게"클릭하여 이메일을 보내면서 찾을 수 있습니다. 나는 이것이 매우 유익하다는 것을 알았습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top