简体   繁体   中英

How do I add a rate me button to an app that has not been released?

So I am about to launch an app to the App Store. My issue is that I have a rate my app please button but I do not know the right code to insert there.

My fiends tried this on their app and said it was no good:

Does anybody know how I can fix this issue?

 let iTunesReviewPageLink = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=1073785561&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8"

        // Go directly to review page on App Store
        if let url = NSURL(string: iTunesReviewPageLink) {
            UIApplication.sharedApplication().openURL(url)
        }

The only unknown thing is the ID, right? You can see the ID of your app before it is published - once you set it up in iTunes Connect.

If your app is not yet released, you haven't got an App Store link. So that's impossible.

In order to implement this functionality when your app is released, you can use the following code:

Swift 2

let appIDString = "APP_ID" // your app ID

let reviewsURLString = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8&id=\(appIDString)"
let reviewsURL = NSURL(string: reviewsURLString)

if reviewsURL != nil && UIApplication.sharedApplication().canOpenURL(reviewsURL!) {

    UIApplication.sharedApplication().openURL(reviewsURL!)
}
else {

    // handle situation if reviews url cannot be opened.
}

Swift 3

let appIDString = "APP_ID" // your app ID

let reviewsURLString = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8&id=\(appIDString)"
let reviewsURL = URL(string: reviewsURLString)

if reviewsURL != nil && UIApplication.shared.canOpenURL(reviewsURL!) {

   UIApplication.shared.openURL(reviewsURL!)
}
else {

    // handle situation if reviews url cannot be opened.
}

EDIT:

This links works in iOS 8 and 9 and links directly to reviews page of the app in App Store application. I am not sure about iOS 7. Probably for iOS 7 you need to use different link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM