我创造一个免费版本的我的游戏。我希望有一个按钮内的免费版本,需要人们付费版本。如果我使用一个标准的链接

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8

iPhone开Safari,然后再应用。我已经使用的其他应用程序开启的程序,储存直接,所以我知道这是可能的。

任何想法?什么是URL方案的应用程序的商店?

有帮助吗?

解决方案

编辑于2016-02-02

从iOS 6开始 SKStoreProductViewController 类。您可以在不离开应用的情况下关联应用。 Swift 3.x / 2.x Objective-C 中的代码段为这里

  

SKStoreProductViewController 对象提供一个允许的商店   用户从App Store购买其他媒体。例如,您的应用   可能会显示商店以允许用户购买另一个应用程序。


来自 Apple开发者的新闻和公告

  

直接将客户引导至您的应用   在App Store上使用iTunes链接   使用iTunes链接,您可以提供   客户可以轻松访问   您的应用程序直接在App Store上   来自您的网站或营销   活动。创建iTunes链接是   简单,可以直接   客户要么是一个应用程序,所有   您的应用,或与特定的应用程序   指定了您的公司名称。

     

向客户发送具体信息   应用:    http://itunes.com/apps/appname

     

发送   客户到您拥有的应用程序列表   在App Store上:    http://itunes.com/apps/developername

     

将客户发送到特定应用   将您的公司名称包含在   网址:    http://itunes.com/apps/developername/appname


附加说明:

您可以将http://替换为itms://itms-apps://以避免重定向。

有关命名的信息,请参阅Apple QA1633:

https://developer.apple.com/library/content /qa/qa1633/_index.html

编辑(截至2015年1月):

itunes.com/apps链接应更新为appstore.com/apps。见上面的QA1633,已经更新。新的 QA1629 建议启动商店的这些步骤和代码来自应用程序:

  1. 在您的计算机上启动iTunes。
  2. 搜索您要链接的项目。
  3. 右键单击或按住Control键并单击iTunes中的项目名称,然后选择<!>“;复制iTunes Store URL <!>”;从弹出菜单中。
  4. 在您的应用程序中,使用复制的iTunes URL创建NSURL对象,然后将此对象传递给UIApplicationopenURL:方法以在App Store中打开您的项目。
  5. 示例代码:

    NSString *iTunesLink = @"itms://itunes.apple.com/app/apple-store/id375380948?mt=8";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
    

    Swift 4.2

       let urlStr = "itms-apps://itunes.apple.com/app/apple-store/id375380948?mt=8"
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)
    
        } else {
            UIApplication.shared.openURL(URL(string: urlStr)!)
        }
    

其他提示

如果您想直接在App Store中打开应用程序,请使用:

ITMS的应用程式:// ...

这样它会直接打开设备中的App Store应用程序,而不是先打开iTunes,然后只打开App Store(只使用itms://)

希望有所帮助。


编辑:APR,2017年。 itms-apps://实际上在iOS10中再次运行。我测试了它。

编辑:APR,2013年。 这不再适用于iOS5及更高版本。只需使用

https://itunes.apple.com/app/id378458261

并且没有更多重定向。

从iOS 6开始,使用 SKStoreProductViewController 类正确地执行此操作。

Swift 3.x

func openStoreProductWithiTunesItemIdentifier(identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.present(storeViewController, animated: true, completion: nil)
        }
    }
}

func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
    viewController.dismiss(animated: true, completion: nil)
}
// Usage:
openStoreProductWithiTunesItemIdentifier(identifier: "13432")
  

您可以像这样获取应用程序的itunes项标识符:(而不是静态的)

Swift 3.2

var appID: String = infoDictionary["CFBundleIdentifier"]
var url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(appID)")
var data = Data(contentsOf: url!)
var lookup = try? JSONSerialization.jsonObject(with: data!, options: []) as? [AnyHashable: Any]
var appITunesItemIdentifier = lookup["results"][0]["trackId"] as? String
openStoreProductViewController(withITunesItemIdentifier: Int(appITunesItemIdentifier!) ?? 0)

Swift 2.x

func openStoreProductWithiTunesItemIdentifier(identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProductWithParameters(parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.presentViewController(storeViewController, animated: true, completion: nil)
        }
    }
}

func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
    viewController.dismissViewControllerAnimated(true, completion: nil)
}
// Usage
openStoreProductWithiTunesItemIdentifier("2321354")

<强>目标-C

static NSInteger const kAppITunesItemIdentifier = 324684580;
[self openStoreProductViewControllerWithITunesItemIdentifier:kAppITunesItemIdentifier];

- (void)openStoreProductViewControllerWithITunesItemIdentifier:(NSInteger)iTunesItemIdentifier {
    SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];

    storeViewController.delegate = self;

    NSNumber *identifier = [NSNumber numberWithInteger:iTunesItemIdentifier];

    NSDictionary *parameters = @{ SKStoreProductParameterITunesItemIdentifier:identifier };
    UIViewController *viewController = self.window.rootViewController;
    [storeViewController loadProductWithParameters:parameters
                                   completionBlock:^(BOOL result, NSError *error) {
                                       if (result)
                                           [viewController presentViewController:storeViewController
                                                              animated:YES
                                                            completion:nil];
                                       else NSLog(@"SKStoreProductViewController: %@", error);
                                   }];

    [storeViewController release];
}

#pragma mark - SKStoreProductViewControllerDelegate

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
    [viewController dismissViewControllerAnimated:YES completion:nil];
}
  

你可以这样得到kAppITunesItemIdentifier(app的itunes项目标识符):(而不是静态的)

NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString* appID = infoDictionary[@"CFBundleIdentifier"];
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];
    NSData* data = [NSData dataWithContentsOfURL:url];
    NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    NSString * appITunesItemIdentifier =  lookup[@"results"][0][@"trackId"]; 
    [self openStoreProductViewControllerWithITunesItemIdentifier:[appITunesItemIdentifier intValue]];

2015年夏季开始......

-(IBAction)clickedUpdate
{
    NSString *simple = @"itms-apps://itunes.apple.com/app/id1234567890";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:simple]];
}

将'id1234567890'替换为'id'和'您的十位数字'

  1. 这适用于所有设备

  2. 直接应用商店,没有重定向。

  3. 所有国家商店都可以。

  4. 如果链接的目的是更新您实际所在的应用内容,确实应该转移到 loadProductWithParameters:它是可能更好地使用这个<!>“老式的<!>”;方法

Apple刚刚宣布了appstore.com网址。

https://developer.apple.com/library/ios/ QA / qa1633 / _index.html

  

有三种类型的App Store短链接,有两种形式,一种用于iOS应用,另一种用于Mac应用:

     

公司名称

     

iOS: http://appstore.com/ 例如 http://appstore.com/apple

     

Mac: http://appstore.com/mac/ ,例如 http://appstore.com/mac/apple

     

应用名称

     

iOS: http://appstore.com/ 例如 http://appstore.com/keynote

     

Mac: http://appstore.com/mac/ ,例如 http://appstore.com/mac/keynote

     

公司的应用程序

     

iOS: http://appstore.com/ /例如, http://appstore.com/apple/keynote

     

Mac: http://appstore.com/mac/ /例如, http://appstore.com/mac/apple/keynote

     

大多数公司和应用都有规范的App Store短链接。此规范URL是通过更改或删除某些字符(其中许多字符是非法的或在URL中具有特殊含义(例如,<!>“<!> amp; <!>”;)而创建的。)

     

要创建App Store短链接,请将以下规则应用于您的公司或应用程序名称:

     

删除所有空格

     

将所有字符转换为小写

     

删除所有版权(<!>#169;),商标(<!>#8482;)和注册商标(<!>#174;)符号

     

用&!>引号替换&符号(<!>“<!> amp; <!>”;)和<!>“;

     

删除大多数标点符号(参见清单2中的集合)

     

替换重音和其他<!>“装饰<!>”;字符(<!>#252;,<!>#229;等)及其元素字符(u,a等)

     

保留所有其他字符。

     

清单2必须删除的标点符号。

     !<!>; <!>

#161 QUOT;#$%'()* +, - / :; LT。<!>; <!>; <!>?= GT#191; @ [] ^ _` {|}〜

     

以下是一些示例,用于演示发生的转换。

     

App Store

     

公司名称示例

     

Gameloft = <!> gt; http://appstore.com/gameloft

     

Activision Publishing,Inc。= <!> gt; http://appstore.com/activisionpublishinginc

     

陈的摄影<!>放大器;软件= <!> gt; http://appstore.com/chensphotographyandsoftware

     

应用名称示例

     

Ocarina = <!> gt; http://appstore.com/ocarina

     

在哪里<!>#8217;我的佩里? = GT <!>; http://appstore.com/wheresmyperry

     

大脑挑战<!>#8482; = GT <!>; http://appstore.com/brainchallenge

此代码在iOS上生成App Store链接

NSString *appName = [NSString stringWithString:[[[NSBundle mainBundle] infoDictionary]   objectForKey:@"CFBundleName"]];
NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.com/app/%@",[appName stringByReplacingOccurrencesOfString:@" " withString:@""]]];

在Mac上用http替换itms-apps:

NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"http:/itunes.com/app/%@",[appName stringByReplacingOccurrencesOfString:@" " withString:@""]]]; 

在iOS上打开网址:

[[UIApplication sharedApplication] openURL:appStoreURL];

的Mac:

[[NSWorkspace sharedWorkspace] openURL:appStoreURL];

只需在应用链接中将'itunes'更改为'phobos'即可。

拥有没有重定向的直接链接:

  1. 使用iTunes链接制作工具 http://itunes.apple.com/linkmaker/ 获取真正的直接链接
  2. http://替换为itms-apps://
  3. 使用[[UIApplication sharedApplication] openURL:url];
  4. 打开链接

    请注意,这些链接仅适用于实际设备,而不适用于模拟器。

    来源: https://developer.apple.com/library /ios/#qa/qa2008/qa1629.html

这对我来说非常适合使用APP ID:

 NSString *urlString = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",YOUR_APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

重定向的数量为零。

许多答案建议使用'itms'或'itms-apps',但Apple并未特别推荐此做法。他们只提供以下方式来打开App Store:

清单1 从iOS应用程序启动App Store

NSString *iTunesLink = @"https://itunes.apple.com/us/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

请参阅 https://developer.apple.com/library/ios /qa/qa1629/_index.html 上次更新于2014年3月,截至此答案。

对于支持iOS 6及更高版本的应用,Apple提供了一种用于展示App Store的应用内机制:SKStoreProductViewController

- (void)loadProductWithParameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL result, NSError *error))block;

// Example:
SKStoreProductViewController* spvc = [[SKStoreProductViewController alloc] init];
spvc.delegate = self;
[spvc loadProductWithParameters:@{ SKStoreProductParameterITunesItemIdentifier : @(364709193) } completionBlock:^(BOOL result, NSError *error){ 
    if (error)
        // Show sorry
    else
        // Present spvc
}];

请注意,在iOS6上,如果有错误,可能无法调用完成块。这似乎是在iOS 7中解决的错误。

如果您想链接到开发者的应用,并且开发人员的名称有标点符号或空格(例如开发公司,LLC),请构成您的网址:

itms-apps://itunes.com/apps/DevelopmentCompanyLLC

否则返回<!>“;此请求无法处理<!>”;在iOS 4.3.3上

您可以通过以下链接制作商获取指向应用商店或iTunes中特定商品的链接: http://itunes.apple.com/linkmaker/

这在ios5中正常工作并直接链接

NSString *iTunesLink = @"http://itunes.apple.com/app/baseball-stats-tracker-touch/id490256272?mt=8";  
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

这是在app store上重定向/链接其他现有应用程序的简单方法。

 NSString *customURL = @"http://itunes.apple.com/app/id951386316";

 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
 {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
 } 

对于Xcode 9.1和Swift 4:

  1. 导入StoreKit:
  2. import StoreKit
    

    2.遵守协议

    SKStoreProductViewControllerDelegate
    

    3.实施协议

    func openStoreProductWithiTunesItemIdentifier(identifier: String) {
        let storeViewController = SKStoreProductViewController()
        storeViewController.delegate = self
    
        let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
        storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, error) -> Void in
    
            if loaded {
                // Parent class of self is UIViewContorller
                self?.present(storeViewController, animated: true, completion: nil)
            }
        }   
    }
    

    3.1

    func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
        viewController.dismiss(animated: true, completion: nil)
    }
    
    1. 使用方法:
    2. openStoreProductWithiTunesItemIdentifier(identifier: "here_put_your_App_id")
      

      注意:

        

      输入您的APP的确切ID非常重要。因为这会导致错误(不显示错误日志,但因此没有任何效果)

我可以确认,如果您在iTunes中创建应用,则会在提交之前获得应用ID。

因此..

itms-apps://itunes.apple.com/app/id123456789

NSURL *appStoreURL = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id123456789"];
    if ([[UIApplication sharedApplication]canOpenURL:appStoreURL])
        [[UIApplication sharedApplication]openURL:appStoreURL];

运作一种享受

在支持多个操作系统和多个平台时,创建链接可能会成为一个复杂的问题。例如,iOS 7(其中一些)不支持WebObjects,您创建的某些链接将打开另一个国家/地区商店,然后是用户等。

有一个名为 iLink 的开源库可以为您提供帮助。

这个库的优点是可以在运行时找到并创建链接(库会检查应用程序ID及其运行的操作系统,并找出应该是什么链接创建)。最好的一点是,在使用之前几乎不需要配置任何东西,这样就没有错误,并且总能正常工作。如果您在同一个项目中的目标很少,那么这也很棒,因此您无需记住要使用的应用ID或链接。如果用户同意,如果商店上有新版本(这是内置的,你通过一个简单的标志关闭它),该库也会提示用户升级应用程序,直接指向应用程序的升级页面。

将2个库文件复制到项目中(iLink.h <!> amp; iLink.m)。

在你的appDelegate.m上:

#import "iLink.h"

+ (void)initialize
{
    //configure iLink
    [iLink sharedInstance].globalPromptForUpdate = YES; // If you want iLink to prompt user to update when the app is old.
}

并在您要打开评级页面的地方,例如使用:

[[iLink sharedInstance] iLinkOpenAppPageInAppStoreWithAppleID: YOUR_PAID_APP_APPLE_ID]; // You should find YOUR_PAID_APP_APPLE_ID from iTunes Connect 

不要忘记在同一个文件中导入iLink.h。

整个图书馆有一个非常好的文档和iPhone和Mac的示例项目。

至少iOS9和上

  • 打开在应用程序直接的商店

一个应用程序

itms-apps://itunes.apple.com/app/[appName]/[appID]

列表中开发的应用程序

itms-apps://itunes.apple.com/developer/[developerName]/[developerID]

根据 Apple的最新文档 你需要使用

appStoreLink = "https://itunes.apple.com/us/app/apple-store/id375380948?mt=8"  

SKStoreProductViewController 

如果您拥有应用商店ID,则最好使用它。特别是如果您将来可能更改应用程序的名称。

http://itunes.apple.com/app/id378458261

如果您没有应用商店ID,则可以根据此文档创建网址 https://developer.apple.com/library/ios/qa/qa1633/_index.html

+ (NSURL *)appStoreURL
{
    static NSURL *appStoreURL;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        appStoreURL = [self appStoreURLFromBundleName:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]];
    });
    return appStoreURL;
}

+ (NSURL *)appStoreURLFromBundleName:(NSString *)bundleName
{
    NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.com/app/%@", [self sanitizeAppStoreResourceSpecifier:bundleName]]];
    return appStoreURL;
}

+ (NSString *)sanitizeAppStoreResourceSpecifier:(NSString *)resourceSpecifier
{
    /*
     https://developer.apple.com/library/ios/qa/qa1633/_index.html
     To create an App Store Short Link, apply the following rules to your company or app name:

     Remove all whitespace
     Convert all characters to lower-case
     Remove all copyright (©), trademark (™) and registered mark (®) symbols
     Replace ampersands ("&") with "and"
     Remove most punctuation (See Listing 2 for the set)
     Replace accented and other "decorated" characters (ü, å, etc.) with their elemental character (u, a, etc.)
     Leave all other characters as-is.
     */
    resourceSpecifier = [resourceSpecifier stringByReplacingOccurrencesOfString:@"&" withString:@"and"];
    resourceSpecifier = [[NSString alloc] initWithData:[resourceSpecifier dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding];
    resourceSpecifier = [resourceSpecifier stringByReplacingOccurrencesOfString:@"[!¡\"#$%'()*+,-./:;<=>¿?@\\[\\]\\^_`{|}~\\s\\t\\n]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, resourceSpecifier.length)];
    resourceSpecifier = [resourceSpecifier lowercaseString];
    return resourceSpecifier;
}

通过此测试

- (void)testAppStoreURLFromBundleName
{
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Nuclear™"].absoluteString, @"itms-apps://itunes.com/app/nuclear", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Magazine+"].absoluteString, @"itms-apps://itunes.com/app/magazine", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Karl & CO"].absoluteString, @"itms-apps://itunes.com/app/karlandco", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"[Fluppy fuck]"].absoluteString, @"itms-apps://itunes.com/app/fluppyfuck", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Pollos Hérmanos"].absoluteString, @"itms-apps://itunes.com/app/polloshermanos", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Niños and niñas"].absoluteString, @"itms-apps://itunes.com/app/ninosandninas", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Trond, MobizMag"].absoluteString, @"itms-apps://itunes.com/app/trondmobizmag", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"!__SPECIAL-PLIZES__!"].absoluteString, @"itms-apps://itunes.com/app/specialplizes", nil);
}

尽管这里有大量的答案,但链接到开发人员应用程序的建议似乎都没有了。

当我上次访问时,我能够使用以下格式使其工作:

itms-apps://itunes.apple.com/developer/developer-name/id123456789

这不再有效,但删除开发者名称会:

itms-apps://itunes.apple.com/developer/id123456789

试试这种方式

http://itunes.apple.com/lookup?id= <!> “;您的应用ID在这里<!>”;返回json。从这里,找到键<!>“; trackViewUrl <!>”;和值是所需的网址。使用此网址(只需将https://替换为itms-apps://)。这很好用。

例如,如果您的应用ID是xyz,请转到此链接 http://itunes.apple.com/lookup?id=xyz

然后找到密钥<!>“ trackViewUrl <!>”的网址。这是您的应用商店应用的网址,并在xcode中使用此网址尝试此

NSString *iTunesLink = @"itms-apps://itunes.apple.com/us/app/Your app name/id Your app ID?mt=8&uo=4";
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

由于

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top