先前知道可以實作連結到App Store,在App中觸發事件來開啟App Store,並顯示特定App畫面,這時候發現有另一種選擇,就是不用開啟App Store,就能顯示該App在App Store顯示的樣子。這麼做的好處是讓使用者體驗更好,因為我發現自己在使用App時,被導出App時都會很不耐煩XD~因為看完之後,還要按Home鍵來回到原來的App。
這個做法要引入StoreKit:
#import <StoreKit/StoreKit.h>
並且遵從其代理:
SKStoreProductViewControllerDelegate
接著就是在你想要觸發的頁面實作:
/** Theme: Link to App Store IDE: Xcode 6 Language: Objective C Date: 104/04/30 Author: HappyMan Blog: https://cg2010studio.wordpress.com/ */ -(IBAction)ratingButtonClicked:(UIButton *)button { NSString *cAppleID = @"876358558"; if ([SKStoreProductViewController class] != nil) { SKStoreProductViewController *skpvc = [[SKStoreProductViewController alloc] init]; skpvc.delegate = self; NSDictionary *dict = [NSDictionary dictionaryWithObject:cAppleID forKey: SKStoreProductParameterITunesItemIdentifier]; [skpvc loadProductWithParameters:dict completionBlock:nil]; [self.navigationController 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]]; } } #pragma mark - #pragma mark - SKStoreProductViewControllerDelegate - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { [viewController dismissViewControllerAnimated: YES completion: nil]; }
首先判斷當前SDK有無SKStoreProductViewController,有的話當然就能實現App內開啟App Store,否則就App外開啟App Store。
iOS6以前App Store的連結很囉唆,iOS7以後變的簡潔漂亮!
執行時你就會發現,實在太神奇了⋯⋯
乍看之下沒什麼不一樣,仔細瞧最上方功能列,多了「取消」和「Store」,前者可以回到原App,後者可以導到App Store。
而且要讓使用者幫你評論也變得很簡單!老實說,先前遇到App要我幫忙評分,但是一想到要跳出去心想就算了XD~
無論如何,做產品的開發者都要以使用者角度來思考,App要怎麼呈現與運作,才會讓他們使用得很「黑皮」~
參考:App store link for “rate/review this app”、iOS應用內打開App Store應用詳情界面。
Comments on: "[iOS] 應用內連結到App Store" (3)
您好,我嘗試了您撰寫的方式
但在我的專案內卻沒有任何反應,下了中斷點後表示
按下那個按鈕會跑完第18行 但沒有任何反應,此方法已經失效了嗎?
謝謝大大
讚讚
嗨~你那個View Controller有裝在Navigation Controller中嗎?
讚讚
[…] 跟開啟其它App同樣的方式,我們使用URL Scheme。若使用者沒安裝,就幫他導到App Store App吧!如果不想要跳出我們的App,可以參考應用內連結到App Store。 […]
讚讚