Ribs: Interactor should implement UNUserNotificationCenterDelegate?

Created on 26 Jun 2018  路  3Comments  路  Source: uber/RIBs

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..

Most helpful comment

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

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ronzohan picture ronzohan  路  7Comments

edrew08 picture edrew08  路  3Comments

oronbz picture oronbz  路  6Comments

gregoireLem picture gregoireLem  路  4Comments

ZacSweers picture ZacSweers  路  6Comments