ibm-bluemix-mobile-services/bms-clientsdk-cordova-plugin-push

Not possible to determine on if the notification was clicked

Closed this issue · 6 comments

Hello,

Right now it looks like it's impossible to determine if the notification was clicked.

I use the following listener:

 var showNotification = function(notif) {
          alert(JSON.stringify(notif));
        };
 BMSPush.setNotificationStatusListener(showNotification);

But it's result have only 3 statuses:
RECEIVED, QUEUED, OPENED

And I get these statuses in all the cases:

  • If I click the notification from the notification bar
  • If I simply open the application through it's application icon from the home screen
  • If I'm watching the application in the foreground while a notification arrives.

I need to be able to determine if the user actually clicked on the notification somehow. In the source codes I saw a SEEN status but that never arrived to the application.

I guess it's a bug, and without it the plugin is really not usable as it's impossible to determinate where I should do the actions for the notification click or not.

@grosmar You cannot determine the notification click using the Notification Status.... Notification status is for Monitoring page of Push Service.

To identify whether the notification is opened through notification click please use the MFPPushNotificationListener method. Inside this method check for the actionName of the MFPSimplePushNotification object. If its null that means app is in foreground, if its com.ibm.mobilefirst.clientsdk.android.app.IBMPushNotification that means the app opened by a notification click.

if (message.actionName.equals("com.ibm.mobilefirst.clientsdk.android.app.IBMPushNotification")){
         System.out.print("Clicked notification to open app");
 }else  {
     // app is in foreground or app is opened by other actions
}

Thanks, but as you see I use the cordova plugin. So how should I do it through the BMSPush javascript interface? Because it doesn't expose the MFPPushNotificationListener in any form.

@grosmar Yes , please use the registerNotificationsCallback method

var showNotification = function(notif) {
          alert(JSON.stringify(notif));
          var identifierName = notif["identifierName"];
          alert(identifierName);
        };
BMSPush.registerNotificationsCallback(showNotification);

Check the value for identifierName.

Of course I use that listener. But that called every time:

  • if I click the message
  • if the app is in foreground
  • if I start the app with it's homescreen icon.

And "identifierName" doesn't exists (check it out if you don't believe me). It's just an example variable in the documentation that you can substitute with some of those that you mentioned in the documentation.

Please try it yourself to see it's not working. I've really checked everything and I really think the plugin is broken and it doesn't work as it supposed to.

I'm waiting for your reply.

@grosmar Yes listener will get called overtime app is in the foreground. If the app opened via notification centre click or actionable button notification click you will get an identifierName . Else it will be null or undefined

The identifierName object will always be there in the notification. You have to check for that object and i believe you have these lines in the manifest file,

<intent-filter>
                <action android:name="com.yourapp.IBMPushNotification" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

identifierName mentioned in the doc is for actionable push notification.

If this also not working please share your index and android manifest files

Ah sorry, you were right. Somehow I missed every time this property in that case when I clicked.
It's working well!