3

Is there a way to send silent or mixed remote notifications with bluemix? There is no such option in the dashboard.

I want my app to fetch data while it's in background when receiving a remote notification.

Edit (copy-paste from comment):

I meant what is the way to send mixed push notifications from Bluemix side, not how to handle it client side. The solution is to use REST API:

POST https://mobile.eu-gb.bluemix.net/imfpush/v1/apps/$(app_id)/messages 

with body:

"settings": { "apns": { "type":'MIXED' }
Ohad
  • 61
  • 8
  • I'm struggling to find the solution too, it seems that's the type:'Mixed' is not (anymore?) valid in the json model (no mention of it in the bluemix push api reference) – Xav Dec 10 '15 at 23:51

1 Answers1

-1

Handling of notifications is done client-side and what you're wanting to do is certainly possible. Taking from the Bluemix Documentation for Push Notifications linked here

Silent notifications do not appear on the device screen. These notifications are received by the application in the background, which wakes up the application for up to 30 seconds to perform the specified background task. A user might not be aware of the notification arrival. To handle silent push notifications, implement the following method in appDelegate.m.

// For Objective C

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
    NSNumber *contentAvailable = userInfo[@"aps"][@"content-available"];
    if([contentAvailable intValue]== 1){
        [[IMFPushClient sharedInstance] application:application didReceiveRemoteNotification:userInfo];

        //Perform background task
        NSLog(@"Received a silent push..");
        NSLog(@"userInfo: %@", userInfo.description);
        _appDelegateVC.result.text = userInfo.description;
        handler(UIBackgroundFetchResultNewData);
    }
    else{
        //Normal Notification
        [[IMFPushAppManager get] notificationReceived:userInfo];

        NSLog(@"Received a normal notification.");
        NSLog(@"userInfo: %@", userInfo.description);
        _appDelegateVC.result.text = userInfo.description;
        handler(UIBackgroundFetchResultNoData);

    }
    //Success
}

The contentAvailable value that is sent by the server for silent notifications is equal to 1.

James Young IBM
  • 616
  • 1
  • 5
  • 13
  • Hi James, question was about how to send a silent notification using the rest APIs, not how to handle it client side. For some reasons, It doesn't seem to be (anymore?) possible to trigger the silent notification using the REST APIs while documentation mention how to handle it on the client side ! Defining the type of the notification seems to be possible in other "flavors" of the API (worklight server) but not on bluemix... https://mobile.ng.bluemix.net/mbaas-api/#!/push/sendMessage_post_21 – Xav Dec 11 '15 at 00:02