Skip to content

Commit

Permalink
Shows alert for opened push only if could - example app
Browse files Browse the repository at this point in the history
  • Loading branch information
adam1929 authored Dec 18, 2023
1 parent 3d70bb8 commit 57784d3
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions ExponeaSDK/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,27 @@ class AppDelegate: ExponeaAppDelegate {

extension AppDelegate {
func showAlert(_ title: String, _ message: String?) {
let alert = UIAlertController(title: title, message: message ?? "no body", preferredStyle: .alert)
alert.addAction(
UIAlertAction(
title: "Ok",
style: .default,
handler: { [weak self] _ in self?.alertWindow?.isHidden = true }
DispatchQueue.main.sync { [weak self] in
guard let self else {
Exponea.logger.log(.warning, message: "Alert not shown because of lost frame")
return
}
let alert = UIAlertController(title: title, message: message ?? "no body", preferredStyle: .alert)
alert.addAction(
UIAlertAction(
title: "Ok",
style: .default,
handler: { [weak self] _ in self?.alertWindow?.isHidden = true }
)
)
)
if alertWindow == nil {
alertWindow = UIWindow(frame: UIScreen.main.bounds)
alertWindow?.rootViewController = UIViewController()
alertWindow?.windowLevel = .alert + 1
if alertWindow == nil {
alertWindow = UIWindow(frame: UIScreen.main.bounds)
alertWindow?.rootViewController = UIViewController()
alertWindow?.windowLevel = .alert + 1
}
alertWindow?.makeKeyAndVisible()
alertWindow?.rootViewController?.present(alert, animated: true, completion: nil)
}
alertWindow?.makeKeyAndVisible()
alertWindow?.rootViewController?.present(alert, animated: true, completion: nil)
}
}

Expand Down

0 comments on commit 57784d3

Please sign in to comment.