Jak Mogę połączyć się z moją aplikacją w App Store (iTunes)?

Chcę mieć funkcję w mojej aplikacji, gdzie użytkownik może wysłać e-mail do znajomego z adresem URL iTunes do mojej aplikacji. Jak to możliwe?

Dzięki.
Author: logancautrell, 2009-05-04

5 answers

Zamiast długich i mylących adresów URL, które zwykle widzisz, możesz tworzyć linki do sklepu z aplikacjami, które są znacznie prostsze i bardziej logiczne. Sklep iTunes ma ukryty format adresu URL, który jest o wiele bardziej logiczny. W zależności od tego, do czego linkujesz, wystarczy zbudować adres URL w jednym z tych formatów:

  1. Nazwa wykonawcy lub nazwa dewelopera App Store: http://itunes.com/Artist_Or_Developer_Name
  2. nazwa albumu: http://itunes.com/Artist_Name/Album_Name
  3. Aplikacje: http://itunes.com/app/App_Name
  4. Filmy: http://itunes.com/movie/Movie_Title
  5. TV: http://itunes.com/tv/Show_Title

Wystarczy podać adres url tego formatu w treści tworzonej wiadomości e-mail.

(zauważ, że spacje mogą powodować problemy, ale odkryłem, że pominięcie ich całkowicie działało dla mnie - http://itunes.com/app/FrootGroove przekierowanie do aplikacji nazywa się "Froot Groove".)

(zauważ również, że jeśli to nie działa dla Ciebie, iTunes link maker jest tutaj)

Twój kod będzie coś takiego (wydobyty z mojego, anonimowy i nie przetestowany)

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
W iPhonie 3.0 można robić lepsze rzeczy, ale nie mogę jeszcze o nich mówić.
 46
Author: Jane Sales,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-05-06 08:01:14

W OS 3.0 możesz użyć frameworka MessageUI, aby to zrobić bez opuszczania aplikacji (używając kodu Jane ' s jako alternatywy dla urządzeń sprzed 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:@"[email protected]"];
        [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:[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
}

#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];
}

Zauważ, że twoja klasa musi przyjąć MFMailComposeViewControllerDelegate protokół. Możesz także dołączać załączniki, używać HTML w treści i nie tylko.

 4
Author: Frank Szczerba,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-07-10 17:37:34

Możesz teraz użyć appstore.com/APP_NAME aby uruchomić aplikację w iTunes. Działa to na komputerach i urządzeniach z systemem iOS. Nie jest to jednak tak wiarygodne, jak inne metody. Zobacz odpowiedź tutaj Jak utworzyć vanity url dla apple appStore?

 3
Author: Rick Roberts,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:25:39

Ten kod generuje link do app store automatycznie na podstawie nazwy aplikacji, nic więcej nie jest wymagane, drag & drop :

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);

Daje link jak http://itunes.com/app/angrybirds

 1
Author: Tibidabo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-08 07:12:13

Nawiasem mówiąc, link do aplikacji przy jego ID można znaleźć, odwiedzając sklep Apps dla Twojej aplikacji i klikając "powiedz znajomemu" - następnie wyślij e-mail do siebie. Uważam to za bardzo pouczające.

 0
Author: mobibob,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-01-19 16:20:27