Skip to content

Instantly share code, notes, and snippets.

@shakemno
Created December 6, 2018 09:15
Show Gist options
  • Save shakemno/11eda9d747dfcb8090c194543c8c1170 to your computer and use it in GitHub Desktop.
Save shakemno/11eda9d747dfcb8090c194543c8c1170 to your computer and use it in GitHub Desktop.
Untested idea to handle the native StoreKit in-app Review alert presentation
NotificationCenter
.default.reactive.notifications(forName: nil, object: nil)
.take(duringLifetimeOf: self)
.observe(on: UIScheduler())
.filter { note in
return note.name == Notification.Name.init("UITextEffectsWindowDidRotateNotification")
}
.observeValues { (note) in
print("⚠️ \(UIApplication.shared.windows.count)")
for window in UIApplication.shared.windows {
if let controller = window.rootViewController {
print("🔺 \(type(of: controller))")
// Count subviews of the windows viewcontroller view not containing ROOTVIEWCONTROLLER.
guard type(of: controller) != ROOTVIEWCONTROLLER.self else {
continue
}
for view in controller.view.subviews {
print("🔻 \(view) : \(view.subviews)")
// If view.subviews > 2 the window is probably presenting a view...
for sub in view.subviews {
print("🔻 \(sub) : \(sub.subviews)")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment