I suppose since UNUserNotificationCenterDelegate declares business rules about receiving notification, the best place to implement that is at Interactor. However, UNUserNotificationCenterDelegate requires that the "implementer" be a NSObject. But I can't make Interactor be a NSObject.
I need some tips and thanks in advance..
Just create something like a UserNotificationsHander service and add it as a dependency to your interactor
I often implement the UNUserNotificationCenterDelegate on the same level as the AppDelegate and then utilize workflows to trigger behavior into the RIBs tree. This allows receiving a notification at the root and ensuring your app is launched in the correct state to handle the notification.
For example, if you receive a notification for a new message but user must be signed in to read the message, then a workflow will trigger the sign in and then after that is complete, continue with the workflow and then attach the RIB to read the new message.
If the UNUserNotificationCenterDelegate is owned somewhere deeper into the RIB tree, then you may not receive notifications until that RIB is attached (which may be the behavior that you're looking for) in which case you can create some Handler class that extends NSObject and have that injected into your Interactor
Closing as answered, thanks @dsrees!
Most helpful comment
I often implement the
UNUserNotificationCenterDelegateon the same level as theAppDelegateand then utilize workflows to trigger behavior into the RIBs tree. This allows receiving a notification at the root and ensuring your app is launched in the correct state to handle the notification.For example, if you receive a notification for a new message but user must be signed in to read the message, then a workflow will trigger the sign in and then after that is complete, continue with the workflow and then attach the RIB to read the new message.
If the
UNUserNotificationCenterDelegateis owned somewhere deeper into the RIB tree, then you may not receive notifications until that RIB is attached (which may be the behavior that you're looking for) in which case you can create someHandlerclass that extendsNSObjectand have that injected into yourInteractor