+

Search Tips | Advanced Search

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


Scenario 4: Existing applications using tag notifications in their application

Client

  1. Initialize the MFPPush client instance in your application and in the success callback register the callback method that should receive the notification.

      MFPPush.initialize(function(successResponse){
      					MFPPush.registerNotificationsCallback(notificationReceived);              					}, 
      					function(failureResponse){
      						alert("Failed to initializeā€);
      					}
      		);

  2. Implement the notification callback method.

      var notificationReceived = function(message) {
      		    alert(JSON.stringify(message));
      	};

  3. Register the mobile device with the push notification service.

       MFPPush.registerDevice(function(successResponse) {
      					alert("Successfully registered");
      				    },
      				  function(failureResponse) {
      					alert("Failed to register");
      				    }
      				);

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

      MFPPush.unregisterDevice(function(successResponse) {
      					alert("Successfully unregistered");
      				    },
      				  function(failureResponse) {
      					alert("Failed to unregister");
      				    }
      				);

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

       MFPPush.isPushSupported (function(successResponse) {
      					alert(successResponse);
      				    },
      				  function(failureResponse) {
      					alert("Failed to get the push suport status");
      				    }
      				);

  6. Remove the following WL.Client.Push APIs:
    1. subscribeTag()
    2. unsubscribeTag()
    3. isTagSubscribed()
    4. onReadyToSubscribe()
    5. onMessage()
  7. Subscribe to tags:

      var tags = ['sample-tag1','sample-tag2'] 
             MFPPush.subscribe(tags, function(successResponse) {
      					alert("Successfully subscribed");
      				    },
      				  function(failureResponse) {
      					alert("Failed to subscribe");
      				    }
      				);

  8. (Optional) Unsubscribe from tags:

       MFPPush.unsubscribe(tags, function(successResponse) {
      					alert("Successfully unsubscribed");
      				    },
      				  function(failureResponse) {
      					alert("Failed to unsubscribe");
      				    }
      				);

Server

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

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 Configure 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 Create tags for push notification.
  4. We can use either of the following methods to send notifications:

Parent topic: Hybrid applications