Restore func hideRatingAlert()

This commit is contained in:
Martin Moizard
2017-11-10 17:00:18 +01:00
parent 90ce675259
commit b3bd6ecc16

View File

@@ -769,7 +769,7 @@ open class Manager : ArmchairManager {
// MARK: Review Alert & Properties // MARK: Review Alert & Properties
#if os(iOS) #if os(iOS)
fileprivate var ratingAlert: UIAlertView? = nil fileprivate var ratingAlert: UIAlertController? = nil
fileprivate let reviewURLTemplate = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&id=APP_ID&at=AFFILIATE_CODE&ct=AFFILIATE_CAMPAIGN_CODE&action=write-review" fileprivate let reviewURLTemplate = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&id=APP_ID&at=AFFILIATE_CODE&ct=AFFILIATE_CAMPAIGN_CODE&action=write-review"
fileprivate let reviewURLTemplateiOS11 = "https://itunes.apple.com/us/app/idAPP_ID?ls=1&mt=8&at=AFFILIATE_CODE&ct=AFFILIATE_CAMPAIGN_CODE&action=write-review" fileprivate let reviewURLTemplateiOS11 = "https://itunes.apple.com/us/app/idAPP_ID?ls=1&mt=8&at=AFFILIATE_CODE&ct=AFFILIATE_CAMPAIGN_CODE&action=write-review"
#elseif os(OSX) #elseif os(OSX)
@@ -1269,7 +1269,9 @@ open class Manager : ArmchairManager {
(alert: UIAlertAction!) in (alert: UIAlertAction!) in
self._rateApp() self._rateApp()
})) }))
ratingAlert = alertView
// get the top most controller (= the StoreKit Controller) and dismiss it // get the top most controller (= the StoreKit Controller) and dismiss it
if let presentingController = UIApplication.shared.keyWindow?.rootViewController { if let presentingController = UIApplication.shared.keyWindow?.rootViewController {
if let topController = Manager.topMostViewController(presentingController) { if let topController = Manager.topMostViewController(presentingController) {
@@ -1752,17 +1754,26 @@ open class Manager : ArmchairManager {
#endif #endif
private func hideRatingAlert() { private func hideRatingAlert() {
#if os(OSX)
if let alert = ratingAlert { if let alert = ratingAlert {
debugLog("Hiding Alert") debugLog("Hiding Alert")
if let window = NSApplication.shared().keyWindow { #if os(iOS)
if let parent = window.sheetParent { let isAlertVisible = alert.isViewLoaded && alert.view.window != nil
parent.endSheet(window) if isAlertVisible {
alert.dismiss(animated: false, completion: {
self.dontRate()
})
} }
} #elseif os(OSX)
if let window = NSApplication.shared.keyWindow {
if let parent = window.sheetParent {
parent.endSheet(window)
}
}
#else
#endif
ratingAlert = nil ratingAlert = nil
} }
#endif
} }
fileprivate func defaultAffiliateCode() -> String { fileprivate func defaultAffiliateCode() -> String {