How can I add a link for a rate button with swift?

前端 未结 13 695
面向向阳花
面向向阳花 2021-01-29 18:57

First I don\'t know how to get the link before I submit my app, and if the link is for each country app store or is it universal?

Also I don\'t know if the way to do it

13条回答
  •  迷失自我
    2021-01-29 19:43

    Try This, change appId in your method by your App ID

    Swift 5

    import StoreKit
    
    func rateApp() {
        if #available(iOS 10.3, *) {
            SKStoreReviewController.requestReview()
    
        } else if let url = URL(string: "itms-apps://itunes.apple.com/app/" + "appId") {
            if #available(iOS 10, *) {
                UIApplication.shared.open(url, options: [:], completionHandler: nil)
    
            } else {
                UIApplication.shared.openURL(url)
            }
        }
    }
    

    Swift 3 \ 4

    func rateApp() {
        guard let url = URL(string: "itms-apps://itunes.apple.com/app/" + "appId") else {
            return
        }
        if #available(iOS 10, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
    
        } else {
            UIApplication.shared.openURL(url)
        }
    }
    

    id959379869 This is the id when you go on your Itune page of your app

    Example : https://itunes.apple.com/fr/app/hipster-moustache/id959379869?mt=8

    How get the ID :

    1. Itunesconnect account
    2. My Apps
    3. Click on "+" Button
    4. New iOS App
    5. Fill require details
    6. After filling all details goto your App
    7. Click on More Button
    8. View on AppStore
    9. It will redirect you to your App URL this will be universal
    10. Look Http URL

提交回复
热议问题