Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension UISplitViewController: SKStoreProductViewControllerDelegate {
- func openStoreProductWithiTunesItemIdentifier(identifier: String) {
- let storeViewController = SKStoreProductViewController()
- storeViewController.delegate = self
- let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
- storeViewController.modalTransitionStyle = .crossDissolve
- if isReachableCurrently() == true {
- present(storeViewController, animated: true, completion: nil)
- storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, error) -> Void in
- if loaded {
- // Parent class of self is UIViewContorller
- // self?.present(storeViewController, animated: false, completion: nil)
- }
- if (error != nil) {
- self?.productViewControllerDidFinish(storeViewController)
- let url = NSURL(string: "itms-apps://itunes.apple.com/app/bars/id1326479187")
- if UIApplication.shared.canOpenURL(url! as URL) {
- UIApplication.shared.open(url! as URL, options: [:],
- completionHandler: {
- (success) in
- print("Open: \(success)")
- })
- }
- }
- }
- } else {
- BMAlert.showNetwordIssuesAlert(on: self)
- }
- }
- public func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
- viewController.modalTransitionStyle = .crossDissolve
- viewController.dismiss(animated: true, completion: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment