Created
May 7, 2019 08:28
-
-
Save shishirthedev/10f34b871a798f771416ce82df9f181a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SafariServices | |
class AppUtils: NSObject { | |
private override init() {} | |
public static let shared: AppUtils = AppUtils() | |
func showSafariVc(in vc: UIViewController, for url: String){ | |
guard let url = URL(string: url) else { return } | |
let safariVc = SFSafariViewController(url: url) | |
vc.present(safariVc, animated: true, completion: nil) | |
} | |
func reviewAppOnAppStore(appleID: String?){ | |
guard let appId = appleID else { return } | |
let appStoreLink = "https://itunes.apple.com/app/id\(appId)?action=write-review" | |
if let url = URL(string: appStoreLink) { | |
if #available(iOS 10.0, *) { | |
UIApplication.shared.open(url, options: [:], completionHandler: nil) | |
} else { | |
// Earlier versions | |
if UIApplication.shared.canOpenURL(url as URL) { | |
UIApplication.shared.openURL(url as URL) | |
} | |
} | |
} | |
} | |
func openAppOnAppStore(appleId: String){ | |
let appStoreLink: String = "itms-apps://itunes.apple.com/app/id\(appleId)" | |
if let url = URL(string: appStoreLink) { | |
if #available(iOS 10.0, *) { | |
UIApplication.shared.open(url, options: [:], completionHandler: nil) | |
} else { | |
// Earlier versions | |
if UIApplication.shared.canOpenURL(url as URL) { | |
UIApplication.shared.openURL(url as URL) | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment