In app development, there are often features that invite users to rate apps. In iOS, the official app is downloaded through AppStore, so the app can be scored only in AppStore. Therefore, you need to jump from the app to AppStore. The method is to open the URL of the response. The code is as follows:
NSString *appid = @ "1234567"; NSString *str = [NSString stringwithformat:@ "itms-apps://itunes.apple.com/cn/app/id%@?mt=8", AppID]; Nsurl *url = [Nsurl urlwithstring:str]; [[UIApplication sharedapplication] openurl:url];
Where AppID is an app release, Apple claims a bunch of numbers that do not need to be set up, and the project name is not the same as the ID. When using, only need to change the AppID to their own appid, the previous URL does not need to change.
In some cases, the company may have a variety of apps, so there will be a need: Each app has a product recommendation feature, through the current app can open other apps (already installed), if not installed, then skip to AppStore download.
For example, the Input Method app can recommend Sogou search, when the user click on the Sogou search icon, the current user to detect whether the app on the phone. If so, open the app directly and if not, jump to AppStore to download the app.
Jump to AppStore download need to know the URL of the app. To open the app locally, you need to know the app's ID (project name, such as Com.sogou.search) and protocol name (can have, can not, such as Sohu), the final URL is the protocol name://app ID, such as sohu:// Com.sogou.search.
The code is as follows:
Nsurl *customurl = [Nsurl urlwithstring:[nsstring stringwithformat:@ "%@://%@", Product.scheme,product.identifier]]; UIApplication *app = [UIApplication sharedapplication];if ([app Canopenurl:customurl]) { //have app installed, open app [app Openurl:customurl];} else{ [app Openurl:[nsurl URLWithString:product.url];}
Open native apps, open AppStore apps, and app scoring for iOS development