¿Cómo puedo enlazar a mi aplicación en la App Store (iTunes)?


Quiero tener una función en mi aplicación donde el usuario pueda enviar un correo electrónico a un amigo con la URL de iTunes a mi aplicación. ¿Cómo es posible?

Gracias.

Author: logancautrell, 2009-05-04

5 answers

En lugar de las url largas y confusas que generalmente ves, puedes crear enlaces de App Store que sean mucho más simples y lógicos. El iTunes Store tiene un formato de URL oculto que es mucho más lógico. Dependiendo de lo que estés enlazando, solo necesitas construir una URL en uno de estos formatos:

  1. Nombre del artista o nombre del desarrollador de App Store: http://itunes.com/Artist_Or_Developer_Name
  2. Nombre del álbum: http://itunes.com/Artist_Name/Album_Name
  3. Aplicaciones: http://itunes.com/app/App_Name
  4. Películas: http://itunes.com/movie/Movie_Title
  5. TV: http://itunes.com/tv/Show_Title

Simplemente incluya una url de este formato en el cuerpo del correo electrónico que cree.

(Tenga en cuenta que los espacios pueden causar problemas, pero descubrí que omitirlos por completo funcionó para mí - http://itunes.com/app/FrootGroove redirige a la aplicación llamado "Froot Groove".)

(También tenga en cuenta que si esto no funciona para usted, el creador de enlaces de iTunes está aquí)

Su código será algo como esto (extraído del mío, anónimo y no probado)

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

Usted puede hacer mejores cosas en el iPhone 3.0, pero no puedo hablar de ellos todavía.

 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-05-06 08:01:14

En OS 3.0 puede usar el framework MessageUI para hacer esto sin salir de la aplicación (usando el código de Jane como alternativa para dispositivos anteriores a la 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];
}

Tenga en cuenta que su clase debe adoptar el protocolo MFMailComposeViewControllerDelegate. También puede incluir archivos adjuntos, usar HTML en el cuerpo y más.

 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-07-10 17:37:34

Ahora puede usar appstore.com/APP_NAME para iniciar una aplicación en iTunes. Esto funciona en el escritorio y en dispositivos iOS. Sin embargo, esto no es tan confiable como otros métodos. Ver respuesta aquí ¿ Cómo crear vanity url para 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:25:39

Este código genera el enlace de la tienda de aplicaciones automáticamente basado en el nombre de la aplicación, no se requiere nada más, arrastrar y soltar :

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

Te da un enlace como 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-03-08 07:12:13

Por cierto, el enlace a la aplicación por su ID se puede encontrar visitando la Tienda de Aplicaciones para su aplicación y haciendo clic en el "Decirle a un amigo" then luego enviar un correo electrónico a ti mismo. Encontré esto muy informativo.

 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-01-19 16:20:27