-
Notifications
You must be signed in to change notification settings - Fork 1
Custom event handling
It is possible for the developer to implement a custom event handling. One might want to perform some custom actions before performing the event's actions to the user like displaying web page, opening deep link or Apple wallet (Passbook). Developer might also want to maybe pop some custom dialog to ask user for permission to perform action. There is a solution for such need in the Ubudu SDK.
To turn on custom event handling the following methods from UbuduSDKDelegate can be implemented:
(iOS 10 or newer)
- (void)ubudu:(UbuduSDK *)ubuduSDK shouldExecuteNotificationRequest:(UNNotificationRequest *)notificationRequest triggeredBy:(UbuduTriggerSource)trigger completionBlock:(void(^)(BOOL shouldExecuteLocalNotificationRequest))completionBlock;
(pre iOS 10)
- (void)ubudu:(UbuduSDK *)ubuduSDK shouldExecuteLocalNotificationRequest:(UILocalNotification *)localNotification triggeredBy:(UbuduTriggerSource)trigger completionBlock:(void(^)(BOOL shouldExecuteLocalNotificationRequest))completionBlock;
This gives you the opportunity to stop / allow action execution of type "local notification". This method is useful if decision about executing the action is a long lasting process. Just call completionBlock with YES to execute an action or call it with NO to stop its execution. Implement it instead of
- (BOOL)ubudu:(UbuduSDK *)ubuduSDK shouldExecuteNotificationRequest:(UNNotificationRequest *)notificationRequest triggeredBy:(UbuduTriggerSource)trigger;
(iOS 10 or newer)
- (void)ubudu:(UbuduSDK *)ubuduSDK shouldExecuteLocalNotificationRequest:(UILocalNotification *)localNotification triggeredBy:(UbuduTriggerSource)trigger completionBlock:(void(^)(BOOL shouldExecuteLocalNotificationRequest))completionBlock;
(pre iOS 10)
If completionBlock is called with YES then SDK will call (if implemented)
- (void)ubudu:(UbuduSDK *)ubuduSDK executeNotificationRequest:(UNNotificationRequest *)notificationRequest triggeredBy:(UbuduTriggerSource)trigger;
(iOS 10)
or
- (void)ubudu:(UbuduSDK *)ubuduSDK executeLocalNotificationRequest:(UILocalNotification *)localNotification triggeredBy:(UbuduTriggerSource)trigger;
in which developer should notify user for event in a custom way.
If after some custom processing the developer wants to perform default actions defined in the Ubudu Manager website, the following method can be called to do it:
[[UbuduSDK sharedInstance] executeLocalNotificationActions:notification];
(pre iOS 10)
or
[[UbuduSDK sharedInstance] executeLocalNotificationActions:notificationRequest];
(iOS 10)
It sends back the notification to the SDK so it can trigger the right actions linked to the notification (open a web view, passbook pass or a deep link) and post open_notif type of analytic log meaning that the notification has been really opened by the user. After calling this the rule handling is over. Because of that it is a good idea to call that method for instance from:
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler