For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Scenario 2: Existing applications using multiple event sources in their application

Applications using multiple event sources requires segmentation of users based on subscriptions.

Client

This maps to tags which segments the users/devices based on topic of interest. To migrate this to MobileFirstV8.0.0, convert this model to tag based notification.

  1. Initialize the MFPPush client instance in your application.

    [[MFPPush sharedInstance] initialize];

  2. Implement the notification processing in the didReceiveRemoteNotification().
  3. Register the mobile device with the push notification service:

    [[MFPPush sharedInstance] registerDevice:^(WLResponse *response, NSError *error) { if(error){ NSLog(@"Failed to register"); }else{ NSLog(@"Successfullyregistered"); } }];

  4. (Optional) Un-register the mobile device from the push notification service:

    [MFPPush sharedInstance] unregisterDevice:^(WLResponse *response, NSError *error) { if(error){ NSLog(@"Failed to unregister"); }else{ NSLog(@"Successfully unregistered"); } }];

  5. Remove WLClient.Push.isPushSupported() (if used) and use:

    [[MFPPush sharedInstance] isPushSupported]

  6. Remove the following WLClient.Push API's since there will be no event source to subscribe to and register notification callbacks:
    1. registerEventSourceCallback()
    2. subscribe()
    3. unsubscribe()
    4. isSubscribed()
    5. WLOnReadyToSubscribeListener Implementation
  7. Call sendDeviceToken() in didRegisterForRemoteNotificationsWithDeviceToken.
  8. Subscribe to tags:

    NSMutableArray *tags = [[NSMutableArray alloc]init]; [tags addObject:@"sample-tag1"]; [tags addObject:@"sample-tag2"]; [MFPPush sharedInstance] subscribe:tags completionHandler:^(WLResponse *response, NSError *error) { if(error){ NSLog(@"Failed to unregister"); }else{ NSLog(@"Successfully unregistered"); } }];

  9. (Optional) Unsubscribe from tags:

    NSMutableArray *tags = [[NSMutableArray alloc]init]; [tags addObject:@"sample-tag1"]; [tags addObject:@"sample-tag2"]; [MFPPush sharedInstance] unsubscribe:tags completionHandler:^(WLResponse *response, NSError *error) { if(error){ NSLog(@"Failed to unregister"); }else{ NSLog(@"Successfully unregistered"); } }];

Server

  1. Remove the following WL.Server API's (if used) in your adapter:

    • notifyAllDevices()
    • notifyDevice()
    • notifyDeviceSubscription()
    • createEventSource()

Complete the following steps for every application that was using the same event source:

  1. Set up the credentials by using the MobileFirst Operations Console. See Configuring push notification settings.

    We can also set up the credentials by using Update GCM settings (PUT) REST API, for Android applications or Update APNs settings (PUT) REST API, for iOS applications.

  2. Add the scope push.mobileclient in Scope Elements Mapping.
  3. Create tags to enable push notifications to be sent to subscribers. See Creating tags for push notification.
  4. We can use either of the following methods to send notifications:

Parent topic: Native iOS applications