Swift jumps from apps to App Store page and reviews ratings

Source: Internet
Author: User

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 ()

}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.