0
votes

Note: When I write "alert view", I'm referring to a UIAlertController UIAlertControllerStyleAlert

When my app is foregrounded after a minimum amount of time, a customPinUnlockViewController appears. This behavior occurs in iOS 8 and iOS 9 (and possibly other versions, but I haven't tested others)

If the user has enabled TouchID, then an alert view appears over the PinUnlockVC, prompting the user to use TouchID to unlock the app instead of entering the pin.

When I press the home button, the alert view is dismissed. The app is NOT backgrounded- only the alert view is dismissed. This is NOT desired behavior, but it appears that it is the default OS behavior.

Anywhere else in the app, when I press the home button, the app is backgrounded. This is desired behavior.

How do I override, what appears to be the default OS functionality in this case, the home button press in order to background the app if an alert view is visible?

I'm not sure if this occurs when any alert view is visible, or if it specific to a TouchID prompt alert view (though I don't see why it would be specific to this case).

Thanks in advance.

1
Why was this down voted? - jungledev
Dunno. Not me. In terms of working on it, can you present more evidence that would help diagnose it? - danh
I have the same problem by the Push Notification Alert. By tapping the Home-Button (iPad Air 2 / iOS 11.3) the AlertView disappear and the question is declined. By the question: "If the app can use the camera", the Home-Button is useless until I answer the alert question. Did Apple changed the behaviour of the AlertViews somehow? (Got an upvote from me ;) ) - matzino

1 Answers

1
votes

I haven't confirmed the behavior you're seeing, but if you're right about the problem (app not going to background) and the cause (because there's a UIAlertController presented), then here's an idea for a solution: In viewDidLoad, subscribe to...

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];

Then upon receiving appWillResignActive...

- (void)appWillResignActive:(NSNotification *)notification {
    if ([self.presentedViewController isKindOfClass:[UIAlertController self]]) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}