ios - online - itunrd
如何链接到应用商店中的应用 (15)
我正在创建我的iPhone游戏的免费版本。 我想在免费版里面有一个按钮,让用户在应用商店中获得付费版本。 如果我使用标准链接
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8
iPhone首先打开Safari,然后打开应用商店。 我已经使用其他应用程序直接打开应用程序商店,所以我知道这是可能的。
有任何想法吗? 应用商店的网址方案是什么?
2015年夏季开始...
-(IBAction)clickedUpdate
{
NSString *simple = @"itms-apps://itunes.apple.com/app/id1234567890";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:simple]];
}
用'id'和'你的十位数字'替换'id1234567890'
这适用于所有设备 。
它确实直接进入应用商店,没有重定向。
适用于所有国内商店 。
确实,你应该转向使用
loadProductWithParameters
, 但是如果链接的目的是更新你实际使用的应用程序:最好使用这种“老式”的方法。
至少iOS 9及以上
- 直接在App Store中打开
一款应用
itms-apps://itunes.apple.com/app/[appName]/[appID]
开发人员的应用程序列表
itms-apps://itunes.apple.com/developer/[developerName]/[developerID]
从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]];
只需在应用链接中将“itunes”更改为“phobos”即可。
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8
现在它将直接打开App Store
如果你想直接打开应用程序到App Store,你应该使用:
ITMS-应用:// ...
这样,它将直接在设备中打开App Store应用程序,而不是先到iTunes,然后只打开App Store(只使用itms://时)
希望有所帮助。
编辑:2017年4月。itms-apps://实际上在iOS10中再次运行。 我测试了它。
编辑:四月,2013年。这不再适用于iOS5及以上。 只需使用
https://itunes.apple.com/app/id378458261
并没有更多的重定向。
如果您想链接到开发人员的应用程序,并且开发人员的姓名有标点或空格(例如Development Company,LLC),请按以下方式组织您的URL:
itms-apps://itunes.com/apps/DevelopmentCompanyLLC
否则,它会在iOS 4.3.3上返回“此请求无法处理”
对于Xcode 9.1和Swift 4:
- 导入StoreKit:
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)
}
- 如何使用:
openStoreProductWithiTunesItemIdentifier(identifier: "here_put_your_App_id")
注意:
输入您的APP的确切ID非常重要。 因为这导致错误(不显示错误日志,但没有正常工作,因为这一点)
您可以通过以下链接获取应用商店或iTunes中特定商品的链接: http://itunes.apple.com/linkmaker/ : http://itunes.apple.com/linkmaker/
根据QA1629 itms-apps:
或itms:
不会奏效。 你需要使用
appStoreLink = "https://itunes.apple.com/us/app/apple-store/id375380948?mt=8"
要么
SKStoreProductViewController
此代码在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];
苹果电脑:
[[NSWorkspace sharedWorkspace] openURL:appStoreURL];
要直接链接而不重定向:
- 使用iTunes链接制造商http://itunes.apple.com/linkmaker/获取真正的直接链接
- 用
itms-apps://
替换http://
itms-apps://
- 用
[[UIApplication sharedApplication] openURL:url];
打开链接[[UIApplication sharedApplication] openURL:url];
请注意,这些链接仅适用于实际设备,不适用于模拟器。
资料来源: https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html : https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html
要非常简洁:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]];
如果您想发送给开发人员的所有应用程序,请使用
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/developername"]];
这些适用于iOS 4.1
如果您想链接到开发人员的应用程序,并且开发人员的姓名有标点或空格(例如Development Company,LLC),请按以下方式组织您的URL:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.com/apps/DevelopmentCompanyLLC"]];
否则,它会在iOS 4.3.3上返回“此请求无法处理”
试试这种方式
http://itunes.apple.com/lookup?id= “您的应用程序ID在这里”返回json.From,找到关键“ 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]];
谢谢
这对我完美的工作只使用APP ID:
NSString *urlString = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",YOUR_APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
重定向的数量为零。
这是工作,并直接链接到ios5
NSString *iTunesLink = @"http://itunes.apple.com/app/baseball-stats-tracker-touch/id490256272?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];