Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NOTE: a future update is going to render this code unnecessary.
- let notification = // get a reference to the Rover Notification using your own table data source.
- // Resolve various Rover subsystems from the SDK that you will need to do the below logic.
- // (Change `RoverCampaigns` to `Rover` if you are still targetting 2.x)
- let notificationStore = RoverCampaigns.shared!.resolve(NotificationStore.self)!
- let router = RoverCampaigns.shared!.resolve(Router.self)!
- let dispatcher = RoverCampaigns.shared!.resolve(Dispatcher.self)!
- let eventQueue = RoverCampaigns.shared!.resolve(EventQueue.self)!
- if !notification.isRead {
- // ask Rover to mark the notification as read. Note, if you are showing the unread state in the row, yu may want to book-end this call in `tableView.beginUpdates/endUpdates`, etc.
- notificationStore.markNotificationRead(notification.id)
- }
- // now we have to handle the different behaviours for different kinds of notification:
- switch notification.tapBehavior {
- case .openApp:
- break
- case .openURL(let url):
- if let action = router.action(for: url) as? PresentViewAction {
- action.viewControllerToPresent.transitioningDelegate = self
- dispatcher.dispatch(action, completionHandler: nil)
- } else {
- UIApplication.shared.open(url, options: [:], completionHandler: nil)
- }
- case .presentWebsite(let url):
- if let action = RoverCampaigns.shared!.resolve(Action.self, name: "presentWebsite", arguments: url) {
- if let presentViewAction = action as? PresentViewAction {
- presentViewAction.viewControllerToPresent.transitioningDelegate = self
- }
- dispatcher.dispatch(action, completionHandler: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement