In my iOS app, there is a condition under which I'd like the user to confirm that he wants to receive remote notifications if he hasn't already, then perform the registration (using registerUserNotificationSettings before iOS 10 or requestAuthorizationWithOptions / registerUserNotificationSettings for iOS 10+). The model will then send the device token back to my server when it requests more data.
I'm trying to use a "clean" MVC pattern. Is the following considered a best practice for when the model needs additional information from the user?
- The model determines the condition for remote notifications has been satisfied and determines the user hasn't confirmed wanting remote notifications.
- The model calls a method on the view controller (as a delegate) to ask the user to confirm wanting remote notifications.
- Since the confirmation process happens asynchronously, the view controller then calls a method on the model with the result.
- If the user confirmed, the model registers the user and handles the result. This will involve interaction between the model and app delegate, and iOS may display its own confirmation modal to the user which is ok.
An alternative would be for the model to pass a completion handler to the view controller in step 2, which is passed around and finally executed by the view controller when result is obtained. (A little tricky with UIAlertView before iOS 9 but pretty easy with UIAlertController for iOS 9+.)
Thanks for any thoughts!