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

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

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

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


当前回答

试试这个方法

http://itunes.apple.com/lookup?id=“你的应用ID在这里”返回json。从这里,找到键“trackViewUrl”和值是所需的url。使用这个url(只需将https://替换为itms-apps://)。这工作得很好。

例如,如果你的应用ID是xyz,那么就转到这个链接 http://itunes.apple.com/lookup?id=xyz

然后找到“trackViewUrl”键的url。这是你的应用程序在应用商店的url,在xcode中使用这个url试试这个

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

谢谢

其他回答

对于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是非常重要的。因为这会导致错误(不显示错误日志,但没有任何工作正常,因为这个)

苹果刚刚公布了appstore.com的网址。

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

There are three types of App Store Short Links, in two forms, one for iOS apps, another for Mac Apps: Company Name iOS: http://appstore.com/ for example, http://appstore.com/apple Mac: http://appstore.com/mac/ for example, http://appstore.com/mac/apple App Name iOS: http://appstore.com/ for example, http://appstore.com/keynote Mac: http://appstore.com/mac/ for example, http://appstore.com/mac/keynote App by Company iOS: http://appstore.com// for example, http://appstore.com/apple/keynote Mac: http://appstore.com/mac// for example, http://appstore.com/mac/apple/keynote Most companies and apps have a canonical App Store Short Link. This canonical URL is created by changing or removing certain characters (many of which are illegal or have special meaning in a URL (for example, "&")). 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. Listing 2 Punctuation characters that must be removed. !¡"#$%'()*+,-./:;<=>¿?@[]^_`{|}~ Below are some examples to demonstrate the conversion that takes place. App Store Company Name examples Gameloft => http://appstore.com/gameloft Activision Publishing, Inc. => http://appstore.com/activisionpublishinginc Chen's Photography & Software => http://appstore.com/chensphotographyandsoftware App Name examples Ocarina => http://appstore.com/ocarina Where’s My Perry? => http://appstore.com/wheresmyperry Brain Challenge™ => http://appstore.com/brainchallenge

如果你想直接在app Store中打开应用,你应该使用:

itms-apps: / /……

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


编辑时间:2017年4月。 itms-apps://实际上在iOS10中再次工作。我测试过了。

编辑:2013年4月。 这在iOS5及以上版本中不再适用。只使用

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

也没有更多的重定向。

它会直接打开应用商店

NSString *iTunesLink = @"itms-apps://itunes.apple.com/app/ebl- 
skybanking/id1171655193?mt=8";

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

至少iOS 9及以上版本

直接在App Store打开

一个应用程序

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

开发者的应用程序列表

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