[英]How to link to Update page for our app
We prompt users to upgrade their app if they're running an outdated version.如果用户运行的是过时的版本,我们会提示用户升级他们的应用程序。 When users tap our update button, I use openURL with an address like
itms://itunes.apple.com/us/app/our-app-title/id12345?mt=8
to load the App Store app to the listing for our app.当用户点击我们的更新按钮时,我使用带有类似
itms://itunes.apple.com/us/app/our-app-title/id12345?mt=8
的地址的 openURL 将 App Store 应用加载到我们的列表中应用程序。
With that method, however, the resulting screen has a button labeled "Open" not "Update."然而,使用这种方法,结果屏幕有一个标记为“打开”而不是“更新”的按钮。 If users open the App Store app first, then navigate to our app's listing (or go to the update tab), the button is labeled "Update."
如果用户先打开 App Store 应用程序,然后导航到我们应用程序的列表(或转到更新选项卡),则该按钮将标记为“更新”。
Can I pass the current version as a querystring parameter in the openURL call or is there another way to make sure the Update button is shown?我可以在 openURL 调用中将当前版本作为查询字符串参数传递还是有另一种方法来确保显示更新按钮? I cannot find current documentation on how to do so.
我找不到有关如何执行此操作的当前文档。 (Everything I find is a few years old and refers to the discontinued phobos tool.)
(我发现的一切都是几年前的,指的是已停产的 phobos 工具。)
I would recommend you to try SKStoreProductViewController class. 我建议你尝试SKStoreProductViewController类。 iTunes item identifier can be found in https://itunesconnect.apple.com -> My Apps -> Apple ID .
可以在https://itunesconnect.apple.com - > 我的应用程序 - > Apple ID中找到iTunes项目标识符。
swift : 迅捷 :
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")
objective-c : objective-c :
- (void)openStoreProductViewControllerWithITunesItemIdentifier:(NSInteger)iTunesItemIdentifier {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
storeViewController.delegate = self;
NSNumber *identifier = [NSNumber numberWithInteger:iTunesItemIdentifier];
NSDictionary *parameters = @{ SKStoreProductParameterITunesItemIdentifier:identifier };
UIViewController *viewController = [self topViewController];
[storeViewController loadProductWithParameters:parameters
completionBlock:^(BOOL result, NSError *error) {
if (!result) {
NSLog(@"SKStoreProductViewController: %@", error);
}
}];
[viewController presentViewController:storeViewController animated:YES completion:nil];
[storeViewController release];
}
From News and Announcement For Apple Developers . 来自Apple开发者的新闻和公告 。
Drive Customers Directly to Your App on the App Store with iTunes Links With iTunes links you can provide your customers with an easy way to access your apps on the App Store directly from your website or marketing campaigns.
使用iTunes链接在App Store上直接将您的应用程序驱动到您的应用程序通过iTunes链接,您可以直接从您的网站或营销活动中为您的客户提供在App Store上访问您的应用程序的简便方法。 Creating an iTunes link is simple and can be made to direct customers to either a single app, all your apps, or to a specific app with your company name specified.
创建iTunes链接非常简单,可以将客户引导到单个应用程序,所有应用程序或指定公司名称的特定应用程序。
To send customers to a specific application: http://itunes.com/apps/appname
要将客户发送到特定应用程序: http : //itunes.com/apps/appname
To send customers to a list of apps you have on the App Store: http://itunes.com/apps/developername
要将客户发送到App Store上的应用列表,请访问: http : //itunes.com/apps/developername
To send customers to a specific app with your company name included in the URL: http://itunes.com/apps/developername/appname
要将客户发送到包含在URL中的公司名称的特定应用程序: http : //itunes.com/apps/developername/appname
Additional notes: 补充笔记:
You can replace http://
with itms://
or itms-apps://
to avoid redirects. 您可以使用
itms://
或itms-apps://
替换http://
itms-apps://
以避免重定向。
For info on naming, see Apple QA1633: 有关命名的信息,请参阅Apple QA1633:
https://developer.apple.com/library/ios/#qa/qa1633/_index.html . https://developer.apple.com/library/ios/#qa/qa1633/_index.html 。
Edit (as of January 2015): 编辑(截至2015年1月):
itunes.com/apps links should be updated to appstore.com/apps. itunes.com/apps链接应更新为appstore.com/apps。 See QA1633 above, which has been updated.
见上面的QA1633,已经更新。 A new QA1629 suggests these steps and code for launching the store from an app:
新的QA1629建议从应用程序启动商店的这些步骤和代码:
Sample code: 示例代码:
NSString *iTunesLink = @"itms://itunes.apple.com/us/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Just replace the 1166632935
with your app ID - Swift 4
只需将您的应用ID替换为
1166632935
- Swift 4
UIApplication.shared.open(URL(string: "itms://itunes.apple.com/app/id1166632935")!, options: [:])
We inform our users to open the Updates
tab on the App Store
app and pull down to refresh if the UPDATE
button isn't visible :/ 我们通知用户打开
App Store
应用程序上的“ Updates
选项卡,如果看不到UPDATE
按钮,请下拉刷新:/
I would like to provide an answer for the Xamarin user. 我想为Xamarin用户提供答案。 The following would bring up an alert offering to update and then take the user to the store.
以下内容将显示更新警报,然后将用户带到商店。
async void PromptForVersionUpgrade()
{
var alertController = UIAlertController.Create(Messages.NewVersionTitle, Messages.NewVersionText, UIAlertControllerStyle.Alert);
alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
alertController.AddAction(UIAlertAction.Create(Messages.NewVersionGoToAppStore, UIAlertActionStyle.Default, (obj) =>
{
var storeViewController = new SKStoreProductViewController();
storeViewController.Delegate = this;
storeViewController.LoadProduct(new StoreProductParameters { ITunesItemIdentifier = 999999999 }, (isLoaded, error) =>
{
if (isLoaded)
PresentViewController(storeViewController, true, null);
});
}));
PresentViewController(alertController, true, null);
}
Then the controller you are calling this code from would need to implement the interface 'ISKStoreProductViewControllerDelegate' to make the 'Cancel' button work. 然后,您调用此代码的控制器需要实现接口'ISKStoreProductViewControllerDelegate'以使“取消”按钮工作。 Then 'this' assignable to the 'Delegate' property.
然后'this'可分配给'Delegate'属性。
public partial class MyCurrentController : ISKStoreProductViewControllerDelegate {
async void PromptForVersionUpgrade() { ... }
[Export("productViewControllerDidFinish:")]
public void Finished(SKStoreProductViewController controller)
{
controller.DismissViewController(true, null);
}
...
}
appID
= https://appstoreconnect.apple.com/ -> My Apps -> 'MyAPP' -> App Information -> under GeneralInformation section present Apple ID. appID
= https://appstoreconnect.apple.com/ -> 我的应用程序 -> 'MyAPP' -> 应用程序信息 -> 在 GeneralInformation 部分下显示 Apple ID。
Swift 5:斯威夫特 5:
let params = [SKStoreProductParameterITunesItemIdentifier: appID]
let storeProductVC = SKStoreProductViewController()
storeProductVC.delegate = self
storeProductVC.loadProduct(withParameters: params)
self.present(storeProductVC, animated: true, completion: nil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.