我正在创造自己的iPhone游戏的免费版本。我想在免费版本中添加一个按钮,引导用户进入应用商店中的付费版本。如果我使用标准链接

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

iPhone首先打开Safari,然后打开应用商店。我使用过其他直接打开应用程序商店的应用程序,所以我知道这是可能的。

什么好主意吗?应用商店的URL方案是什么?


当前回答

我可以确认,如果你在iTunes connect上创建应用,你会在提交应用之前获得应用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];

工作是一种享受

其他回答

根据苹果公司的最新文件 你需要使用

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

SKStoreProductViewController 

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

有一个叫做iLink的开源库可以帮助你。

There advantages of this library is that the links would be found and created at run time (the library would check the app ID and the OS it is running on and would figure out what link should be created). The best point in this is that you don't need to configure almost anything before using it so that is error free and would work always. That's great also if you have few targets on same project so you don't have to remember which app ID or link to use. This library also would prompt the user to upgrade the app if there is a new version on the store (this is built in and you turn this off by a simple flag) directly pointing to the upgrade page for the app if user agrees.

复制两个库文件到你的项目(iLink.h & 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的示例项目。

这里的大多数解决方案都过时了

为那些寻找更新的工作解决方案

// let appStoreLink = "https://apps.apple.com/app/{app-name}/{app-id}"

guard let url = URL(string: Constants.App.appStoreLink) else { return }
UIApplication.shared.open(url)

对于Xcode 9.1和Swift 4:

进口StoreKit:

进口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)
}

使用方法:

openStoreProductWithiTunesItemIdentifier(标识符:“here_put_your_App_id”)

注意:

输入你的APP的确切ID是非常重要的。因为这会导致错误(不显示错误日志,但没有任何工作正常,因为这个)

这是重定向/链接应用商店中其他现有应用程序的简单而简短的方法。

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

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