SMAGreg
SMAGreg

Reputation: 48

Hybrid event push-notification for IOS seems like not yet handled on mobilefirst 7.1

Trying to handle notification on an hybrid application. The notification arrives on device (can see it in logs and on device when application closed) but there's no way to handle it by that code:

WL.Client.Push.registerEventSourceCallback(
    "myPush",
    "PushAdapter",
    "PushEventSource",
    function (props, payload) {
        console.log("received notification - in notifications.js")
        alert("moo");
    }
);
console.log("registered event source");

When watching mfp plugin, seems like iOS part missing, how can i handle that notification anyway?

Upvotes: 0

Views: 279

Answers (2)

DoraC
DoraC

Reputation: 332

From what I am understanding, you are saying the issue is that the push notification arrives on device only when app is in background, but when app is in foreground app will not be pushed. And this is only happening for iOS?

Try using this sample to do a simple push in an MFP Cordova application and see if you are still experiencing the same issue. https://github.com/csantanapr/mfp-push-template

Should be pretty simple to setup for iOS. Need to get p12 file, configure XCode to sign with correct profile, set p12 password in app descriptor, set app id in push adapter.

Helpful guide that you've probably used: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/notifications/push-notifications-overview/push-notifications-in-hybrid-applications/

Upvotes: 2

Idan Adar
Idan Adar

Reputation: 44516

Edit: if you are developing a Cordova application, then after configuring push notifications for iOS in the application, the implementation itself is still the same, as is for Classic Hybrid applications - as shown below.

For this matter you could also just take the Hybrid sample and follow the migration guide to have it running in a Cordova app (sans the setup, which is slightly different).


Take a look at main.js: https://github.com/MobileFirst-Platform-Developer-Center/EventSourceNotifications/blob/release71/apps/HybridEventSource/common/js/main.js

Specifically the following, which is the function where you handle the received notification once the application is brought to the foreground:

function pushNotificationReceived(props, payload) {
    alert("pushNotificationReceived invoked");
    alert("props :: " + JSON.stringify(props));
    alert("payload :: " + JSON.stringify(payload));
}

Upvotes: 0

Related Questions