appcues / appcues-ios-sdk

The Appcues iOS SDK
https://www.appcues.com/mobile
MIT License
8 stars 2 forks source link

Ensure push completion handlers are always called #548

Closed mmaatttt closed 2 months ago

mmaatttt commented 2 months ago

Was working on push docs and noticed a two gaps in how the automatic push configuration calls completion handlers. For context:

Docs for userNotificationCenter(_:didReceive:withCompletionHandler:):

You must execute this block at some point after processing the user’s response to let the system know that you are done.

Docs for userNotificationCenter(_:willPresent:withCompletionHandler::

Always execute this block at some point during your implementation of this method.

First off, in PushAutoConfig, the completion handler wasn't being called in the case where there's not an Appcues instance to immediately handle the push, but we save it for deferred handling. I've added the call and some inline docs to make it clearer what's happening.

Then, for the cases where an incoming notification isn't an Appcues one and the app hasn't already implemented the methods, the swizzling implementation falls back (here and here) to an "empty" default implementation that we provide. So those default implementations need to call the completion block as well.