Asking person to fee or overview app in iOS – Swift Tutorial – iOSTutorialJunction

0
5


On this put up, we’ll find out how we will use iOS sdk Storekit framework to ask for app retailer score. With the assistance of SKStoreReviewController we will present person a pop as much as fee our iOS app, that’s too with out leaving the app. Earlier, we open the app retailer app and ask person for app score. So allow us to begin utilizing Storekit framework to let person ask for app retailer score.

Issues to remember whereas including app score pop up utilizing SKStoreReviewController

  1. App score alert might be proven 3 instances throughout a interval of twelve months.
  2. Don’t set off the app score alert on a button click on, as a result of it could or could not present the alert.
  3. App icon is managed by SKStoreReviewController, and fetched out of your app element on iOS app retailer.
  4. SKStoreReviewController is out there in iOS 10.3 and above.

Steps to point out app score alert in iOS utilizing SKStoreReviewController

Step 1: Import StoreKit framework

Step 2: Open your swift class, the place you wish to implement this app score alert. Create a perform to request overview pop up usingSKStoreReviewController class. Under is the code for asking app score pop up.

import UIKit
import StoreKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any further setup after loading the view.
       	self.requestAppReview()
    }
    
    func requestAppReview() {
        if #obtainable(iOS 14.0, *) {
            if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
                SKStoreReviewController.requestReview(in: scene)
            }
        } else {
            SKStoreReviewController.requestReview()
        }
    }
}

Since requestReview is deprecated in IOS 14.0 and onward. So we’ll use, requestReview(in: scene) perform launched after iOS 14.0 and onward. That’s it and we’ve got applied app score pop up in our iOS app. You will note a pop up in your app like this (please ignore the app icon because it’s taken from app that’s already on iOS app retailer).

LEAVE A REPLY

Please enter your comment!
Please enter your name here