0
votes

I have a sample push notification application and adapter with MFP 6.3 version (download from http://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/6.3/notifications/push-notifications-hybrid-applications/).

I have migrated the mobile application to MFP 8.0. In adapter, they have same functions(procedures) like, WL.Server.createEventSource, WL.Server.notifyAllDevices, WL.Server.createDefaultNotification, WL.Server.getUserNotificationSubscription

WL.Server.createEventSource({
    name: 'PushEventSource',
    onDeviceSubscribe: 'deviceSubscribeFunc',
    onDeviceUnsubscribe: 'deviceUnsubscribeFunc',
    securityTest:'PushApplication-strong-mobile-securityTest'
});

function submitNotification(userId, notificationText){
    var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);

    if (userSubscription==null){
        return { result: "No subscription found for user :: " + userId };
    }

    var badgeDigit = 1;

    var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"});

    WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText);

    WL.Server.notifyAllDevices(userSubscription, notification);

    return { 
        result: "Notification sent to user :: " + userId 
    };
}

Is this functions will work on MFP 8.0?

The below mention urls only correct replacement. Right? 1.http://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/#sending-notifications 2.https://www.ibm.com/support/knowledgecenter/en/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/rest_runtime/r_restapi_push_message_post.html#Push-Message--POST-

1

1 Answers

2
votes

Push Notifications underwent major architectural changes besides several functional enhancements between v6.3 to v8.0.

Firstly, With v8.0 there are no Server Side SDKs available out of the box to send Push Notifications from within the adapters. However, doesn't mean this is impossible - you can use the REST APIs directly from within the adapter. Reference: Link 2 in your q. above. Swagger docs are available too with your installation.

Secondly, Event Source based notifications have been removed in v8.0 in favor of Tag based notifications. Please follow the below link on the migration path: http://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/upgrading/migrating-push-notifications/