pushy/pushy-cordova

setNotificationClickListener doesn't work as expect on ios

Closed this issue ยท 9 comments

pushy-cordova@1.0.29
ios 12.3.1

Pushy.setNotificationClickListener(function (data) {
        redirectAfterNoti(data);
        console.log('Clicked notification: ' + JSON.stringify(data));
      });

after i click the notification, setNotificationClickListener doesn't fire, i can't see log on safari debug console. nothing happen

but it fired every time on app resume

pushy commented

Hi @crapthings,
As you mentioned in your e-mail, you are currently using two push plugins at once. This is not supported as both plugins are trying to hook into the APNs AppDelegate delegate methods:

  1. application:didRegisterForRemoteNotificationsWithDeviceToken
  2. application:didFailToRegisterForRemoteNotificationsWithError
  3. application:didReceiveRemoteNotification:fetchCompletionHandler

Please remove the other plugin, and this functionality should work. ๐Ÿ‘

i've already remove the other plugin, but still have this issue

pushy commented

Hi @crapthings,
What version of Cordova (cordova-ios) are you using in your project? Please check your package.json in the dependencies section.

I can confirm this functionality works on a recent version of cordova-ios, 4.5.5.

we're using meteor 1.8.1 currently the bundled cordova is

{
  "android": "7.1.4",
  "ios": "4.5.5"
}
pushy commented

but it fired every time on app resume

Can you please clarify? Are you saying the listener fires every time you resume your app regardless of whether you interacted with a notification?

yes~

it should be fired after i click notification, but its not.

if i hit refresh in safari remote debug mode, the setNotificationClickListener event fires after dom loaded(device ready) and when i put app on background then back it fires(it looks like an resume event to me). i just wrap the setNotiClickListener with Meteor.startup

meteor.startup is like a "device ready callback" on cordova app

Meteor.startup(function () {
  Pushy.setNotificationClickListener(function (data) {
    console.log('Clicked notification: ' + JSON.stringify(data));
  })
})
pushy commented

@crapthings I recommend creating a brand new Meteor project and trying to integrate our Cordova SDK from scratch:
https://pushy.me/docs/additional-platforms/cordova

This may help narrow down the issue which is arising from your custom (mature) project.

As we don't support Meteor currently I can no longer provide support any further on this issue.

okay this work with new meteor project definitely.

i will try to find what cause this prob~

thanks anyway~~~~

Meteor.startup(() => {
  Pushy.listen()
  Pushy.register(function (err, deviceToken) {})
  Pushy.setNotificationClickListener(function (data) {
    console.log('Clicked notification: ' + JSON.stringify(data))
    alert('Clicked notification: ' + data.message)
  })
})
pushy commented

Good luck ๐Ÿ‘