+

Search Tips | Advanced Search

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 in MobileFirst V8.0.0, convert this model to tag based notification.

  1. Initialize the MFPPush client instance in your application:

      MFPPush push = MFPPush.GetInstance();
      push.Initialize();

  2. Implement the interface MFPPushNotificationListener and define onReceive().

      class Pushlistener : MFPPushNotificationListener
      {
          public void onReceive(String properties, String payload)
          { 
                  Debug.WriteLine("Push Notifications\n properties:" + properties + "\n payload:" + payload);
          }
      }

  3. Register the mobile device with the IMFPUSH service.

      MFPPushMessageResponse Response = await push.RegisterDevice(null);
      if (Response.Success == true)
      {
          Debug.WriteLine("Push Notifications Registered successfully");
      } 
      else
      {
          Debug.WriteLine("Push Notifications Failed to register");
      }

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

      MFPPushMessageResponse Response = await push.UnregisterDevice();
      if (Response.Success == true)
      {
          Debug.WriteLine("Push Notifications Failed to unregister");
      }
      else
      {
          Debug.WriteLine("Push Notifications Unregistered successfully");
      }

  5. Remove WLClient.Push.IsPushSupported() (if used) and use push.IsPushSupported();.
  6. Remove the following WLClient.Push APIs since there will be no Event Source to subscribe to and register notification callbacks:
    1. registerEventSourceCallback()
    2. subscribe()
    3. unsubscribe()
    4. isSubscribed()
    5. WLOnReadyToSubscribeListener and WLNotificationListener implementation
  7. Subscribe to tags:

      String[] Tag = { "sample-tag1", "sample-tag2" };
      MFPPushMessageResponse Response = await push.Subscribe(Tag);
      if (Response.Success == true)
      {
          Debug.WriteLine("Subscribed successfully");
      }
      else
      {
          Debug.WriteLine("Failed to subscribe");
      }

  8. (Optional) Unsubscribe from tags:

       String[] Tag = { "sample-tag1", "sample-tag2" };
      MFPPushMessageResponse Response = await push.Unsubscribe(Tag);
      if (Response.Success == true)
      {
          Debug.WriteLine("Unsubscribed successfully");
      }
      else
      {
          Debug.WriteLine("Failed to unsubscribe");
      }

Server

Remove the following WL.Server APIs (if used) in your adapter:

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

  1. Set up the WNS credentials in the Push Settings page of MobileFirst Operations Console or use WNS Settings REST API.
  2. Add the scope push.mobileclient in Map Scope Elements to security checks section in the Security tab of MobileFirst Operations Console.
  3. Create Push tags in the Tags page of MobileFirst Operations Console.
  4. We can also use the Push Message (POST) REST API with userId/deviceId/tagNames as target, to send notifications.

Parent topic: Native Windows Universal applications