Oracle Help Center | Oracle Push Cloud Service (Standalone) title

Passing Extra Data

Push notifications can be sent with "extra" data to further customize where the user is directed or what happens when the notification is engaged upon.

For instance, perhaps you would like to direct a user to a certain in-app page. Or, perhaps you want to send a user to an external URL.

For APNs, you will need to make changes to your AppDelegate.m file to tell your application to act upon push notification "extra" data. In particular, you will be using the didReceiveRemoteNotification method to re-direct the user based on the extra data.

In this example, we will re-direct the user to the web if a "u" key/pair is passed along with your notification.

For iOS 9 and earlier:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    [[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo fetchCompletionResult:UIBackgroundFetchResultNewData fetchCompletionHandler:completionHandler];
    NSString *urlString = [userInfo valueForKeyPath:@"u"];
    NSURL *url = [NSURL URLWithString:urlString];
    [[UIApplication sharedApplication] openURL:url];
}

For iOS 10 support, add:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    [[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo];
    NSString *urlString = [userInfo valueForKeyPath:@"u"];
    NSURL *url = [NSURL URLWithString:urlString];
    [[UIApplication sharedApplication] openURL:url];
}

The extra data can be passed through both the Web Dashboard and via our APIs. The picture below shows where to configure your push in the Web Dashboard UI to pass the extra data:

"PushIO Web Dashboard, Push tab, Advanced Options"

More information on the didReceiveRemoteNotification method and other UIApplicationDelegate protocols can be found here.