iOS去AppStore里評分

注意點?。。?/h3>
  • 要用真機測試才能看效果。
  • 要保持網(wǎng)絡(luò)良好。

1、去AppStore評分有2種方式。由于第一種,不太推薦,因為,還要額外跳轉(zhuǎn),顯得麻煩!下面介紹我常用的方法。就是第二種方法。
2、下面的方法,你只需把代碼拷貝就可以使用了!
  • 首先導(dǎo)入#import <StoreKit/StoreKit.h> // 評分庫
  • 代理 設(shè)置 <SKStoreProductViewControllerDelegate>

-- 實現(xiàn)代理協(xié)議方法

  - (void) viewDidLoad
  {
     // 把要評分的 appId 放在這 -- 這里測試用 《圣誕愿望》
     [self openAppWithIdentifier:@"940489630"];
  }

  /**
   * 實例化一個SKStoreProductViewController類 -- 評分    用
   */

- (void)openAppWithIdentifier:(NSString *)appId {
SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc] init];
storeProductVC.delegate = self;

NSDictionary *dict = [NSDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier];
[storeProductVC loadProductWithParameters:dict completionBlock:^(BOOL result, NSError *error) {
    if (result) {
        [self presentViewController:storeProductVC animated:YES completion:nil];
    }
}];

}
#pragma mark - SKStoreProductViewControllerDelegate 嵌入應(yīng)用商店
/**

  • 按取消按鈕Cancel返回所調(diào)用代理方法,此處返回到ViewController控制器
    */

     - (void)productViewControllerDidFinish:(SKStoreProductViewController *)storeProductVC {
       [storeProductVC dismissViewControllerAnimated:YES completion:^{
    
       [self.navigationController popToRootViewControllerAnimated:YES];
       }];
     }
    

補充:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容