zendesk / outbound_ios_sdk

Connect (formerly Outbound.io) iOS SDK.
https://www.zendesk.com/connect/
MIT License
2 stars 2 forks source link

Added isOutboundNotification to make handling other notifications easier #5

Closed ryan-scott-dev closed 6 years ago

ryan-scott-dev commented 6 years ago

Added isOutboundNotification method to make handling other notifications easier.

Now didReceiveRemoteNotification can be implemented as:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    if ([Outbound isOutboundNotification:userInfo]) {
        [Outbound handleNotificationWithUserInfo:userInfo completion:^(BOOL success) {
            completionHandler(success ? UIBackgroundFetchResultNewData : UIBackgroundFetchResultFailed);
        }];
    } else {
        // Hande non-Outbound notifications here
        completionHandler(UIBackgroundFetchResultNoData);
    }
}

While isOutboundNotification could be rolled into handleNotificationWithUserInfo, we felt that keeping them seperate makes the intention of each function clearer and provides more flexibility.

Changes