我想把一个“率/审查这个应用程序”功能到我的应用程序。
是否存在一种方法能够直接链接到应用商店中他们评论应用的屏幕?所以用户不需要点击主应用程序链接。谢谢。
编辑:由于缺乏回应,开始赏金。为了确保这一点非常清楚:我知道我可以链接到应用商店中我的应用页面,并让用户从那里点击到“审查这款应用”屏幕。问题是是否有可能直接链接到“审查这个应用程序”屏幕,这样他们就不需要点击任何东西。
我想把一个“率/审查这个应用程序”功能到我的应用程序。
是否存在一种方法能够直接链接到应用商店中他们评论应用的屏幕?所以用户不需要点击主应用程序链接。谢谢。
编辑:由于缺乏回应,开始赏金。为了确保这一点非常清楚:我知道我可以链接到应用商店中我的应用页面,并让用户从那里点击到“审查这款应用”屏幕。问题是是否有可能直接链接到“审查这个应用程序”屏幕,这样他们就不需要点击任何东西。
当前回答
对于>= iOS8:(简化@EliBud的回答)。
#define APP_STORE_ID 1108885113
- (void)rateApp{
static NSString *const iOSAppStoreURLFormat = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d";
NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:iOSAppStoreURLFormat, APP_STORE_ID]];
if ([[UIApplication sharedApplication] canOpenURL:appStoreURL]) {
[[UIApplication sharedApplication] openURL:appStoreURL];
}
}
其他回答
以上方法都是正确的,但是现在使用SKStoreProductViewController可以带来更好的用户体验。要使用它,你需要做以下工作:
implement SKStoreProductViewControllerDelegate protocol in your app delegate add required productViewControllerDidFinish method: - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { [viewController dismissViewControllerAnimated: YES completion: nil]; } Check if SKStoreProductViewController class is available and either show it or switch to the App Store: extern NSString* cAppleID; // must be defined somewhere... if ([SKStoreProductViewController class] != nil) { SKStoreProductViewController* skpvc = [[SKStoreProductViewController new] autorelease]; skpvc.delegate = self; NSDictionary* dict = [NSDictionary dictionaryWithObject: cAppleID forKey: SKStoreProductParameterITunesItemIdentifier]; [skpvc loadProductWithParameters: dict completionBlock: nil]; [[self _viewController] presentViewController: skpvc animated: YES completion: nil]; } else { static NSString* const iOS7AppStoreURLFormat = @"itms-apps://itunes.apple.com/app/id%@"; static NSString* const iOSAppStoreURLFormat = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@"; NSString* url = [[NSString alloc] initWithFormat: ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f) ? iOS7AppStoreURLFormat : iOSAppStoreURLFormat, cAppleID]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]]; }
这是我在我的应用程序中使用的代码;
-(void)rateApp {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"itms-apps://itunes.apple.com/app/" stringByAppendingString: @"id547101139"]]];
}
通过SKStoreProductViewController链接到AppStore中的任何应用程序
很容易通过SKStoreProductViewController链接到应用商店的应用程序。但是我有点纠结,所以我决定在这里展示整个过程和一些必要的代码。这种技术还可以确保始终使用正确的商店(对于本地化应用程序很重要)。
要在你的应用程序商店中显示任何应用程序的产品屏幕,你的任何应用程序ViewControllers遵循以下步骤:
在项目设置中添加StoreKit.framework(目标,构建阶段->链接二进制库 导入StoreKit到ViewController类中 使你的ViewController符合这个协议 SKStoreProductViewControllerDelegate 创建方法,将StoreView显示为所需的产品屏幕 解散StoreView
但最重要的是:出于某种原因,这在模拟器中不起作用——你必须在具有互联网连接的真实设备上构建和安装。
添加StorKit.framework到你的项目:
SWIFT 4:这是根据前面描述的步骤编写的代码:
// ----------------------------------------------------------------------------------------
// 2. Import StoreKit into the ViewController class
// ----------------------------------------------------------------------------------------
import StoreKit
// ...
// within your ViewController
// ----------------------------------------------------------------------------------------
// 4. Create the method to present the StoreView with the product screen you want
// ----------------------------------------------------------------------------------------
func showStore() {
// Define parameter for product (here with ID-Number)
let parameter : Dictionary<String, Any> = [SKStoreProductParameterITunesItemIdentifier : NSNumber(value: 742562928)]
// Create a SKStoreProduktViewController instance
let storeViewController : SKStoreProductViewController = SKStoreProductViewController()
// set Delegate
storeViewController.delegate = self
// load product
storeViewController.loadProduct(withParameters: parameter) { (success, error) in
if success == true {
// show storeController
self.present(storeViewController, animated: true, completion: nil)
} else {
print("NO SUCCESS LOADING PRODUCT SCREEN")
print("Error ? : \(error?.localizedDescription)")
}
}
}
// ...
// ----------------------------------------------------------------------------------------
// 3. Make your ViewController conforming the protocol SKStoreProductViewControllerDelegate
// ----------------------------------------------------------------------------------------
extension ViewController : SKStoreProductViewControllerDelegate {
// ----------------------------------------------------------------------------------------
// 5. Dismiss the StoreView
// ----------------------------------------------------------------------------------------
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
print("RECEIVED a FINISH-Message from SKStoreProduktViewController")
viewController.dismiss(animated: true, completion: nil)
}
}
在iOS7中,将你的应用程序切换到app Store进行费率和审查的URL已经更改:
itms-apps://itunes.apple.com/app/idAPP_ID
APP_ID需要替换为您的应用程序ID。
对于iOS 6和更老版本,之前答案中的URL工作正常。
来源:Appirater
享受编码. . ! !
斯威夫特3
fileprivate func openAppStore() {
let appId = "YOUR_APP_ID"
let url_string = "itms-apps://itunes.apple.com/app/id\(appId)"
if let url = URL(string: url_string) {
UIApplication.shared.openURL(url)
}
}