AlertController not showing up with warning: Attempt to present UIAlertController on UINavigationController whose view is not in the window hierarchy! #74

Open
opened 2025-12-29 18:28:55 +01:00 by adam · 1 comment
Owner

Originally created by @sandeepbol on GitHub (May 15, 2018).

I am notifying Armchair of a significant event from a callback of a async request as follows

func onTransactionCompleted(status: TransactionStatus) {
  if (status == .success) {
      DispatchQueue.main.async {
        Armchair.userDidSignificantEvent(true)
      }
  }
}

but Alertcontroller is not shown and debugger shows

warning: Attempt to present UIAlertController on UINavigationController whose view is not in the window hierarchy!

Originally created by @sandeepbol on GitHub (May 15, 2018). I am notifying Armchair of a significant event from a callback of a async request as follows ``` func onTransactionCompleted(status: TransactionStatus) { if (status == .success) { DispatchQueue.main.async { Armchair.userDidSignificantEvent(true) } } } ``` but Alertcontroller is not shown and debugger shows > warning: Attempt to present UIAlertController on UINavigationController whose view is not in the window hierarchy!
Author
Owner

@sandeepbol commented on GitHub (May 15, 2018):

I got around the issue by moving Armchair.userDidSignificantEvent(true) to viewDidAppear:

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        if canShowRatingPrompt {
            Armchair.userDidSignificantEvent(true)
            canShowRatingPrompt = false
        }
    }

But will be happy to hear what might be more clean and best approach.

@sandeepbol commented on GitHub (May 15, 2018): I got around the issue by moving Armchair.userDidSignificantEvent(true) to viewDidAppear: ``` override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if canShowRatingPrompt { Armchair.userDidSignificantEvent(true) canShowRatingPrompt = false } } ``` But will be happy to hear what might be more clean and best approach.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Armchair#74