We often see a lot of apps on the market, and each time it pops up a box and asks if you want to give it a cent on the app store. If you choose to, you will automatically open the App Store and display the home page of the application, where users can write comments and rate them.
This is actually very simple, only need to use the uiapplication.sharedapplication () OpenURL () method to open the corresponding app Store link. In addition to jumping to App store,openurl, there are many other uses, referring to my original article: Swift-open Third-party applications and pass parameters (with URL Scheme for popular apps)
1, Sample Effect chart
When the program starts, it pops up a message box asking whether to evaluate it. Click "OK" to jump to this app's App Store page.
2, sample code
The end of the link address is the AppID of the application you want to jump to, which is automatically generated when you submit the app and is the only ID in the App Store (as a demo, I use QQ appID).
Import Uikit
Class Viewcontroller:uiviewcontroller {
Override Func Viewdidload () {
Super.viewdidload ()
}
Override func Viewdidappear (Animated:bool) {
Pop-up message box
Let Alertcontroller = Uialertcontroller (title: "Feel Good words, give me a comment!" ",
Message:nil, Preferredstyle:. Alert)
Let cancelaction = uialertaction (title: "No comment", style:. Cancel, Handler:nil)
Let okaction = uialertaction (title: "OK", style:. Default,
Handler: {
Action in
Self.gotoappstore ()
})
Alertcontroller.addaction (cancelaction)
Alertcontroller.addaction (okaction)
Self.presentviewcontroller (Alertcontroller, Animated:true, Completion:nil)
}
Jump to App's app page page
Func Gotoappstore () {
Let urlstring = "itms-apps://itunes.apple.com/app/id444934666"
Let URL = Nsurl (string:urlstring)
Uiapplication.sharedapplication (). OpenURL (url!)
}
Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
}
}