Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

IOS button action callbacks not getting called #576

Closed
jopelkey opened this issue Feb 5, 2016 · 3 comments
Closed

IOS button action callbacks not getting called #576

jopelkey opened this issue Feb 5, 2016 · 3 comments

Comments

@jopelkey
Copy link

jopelkey commented Feb 5, 2016

I have been using an earlier version of this plugin successfully for some time w/o action buttons.

But now I want to add action buttons and am having trouble getting the callbacks to work on IOS (I haven't tried Android yet).

I am able to see the buttons and click on them in the notification, but I am only sometimes getting into callbacks. The behavior does not seem to be the same every time, but I have seen where if I send push #1 and click on the yes button (and do NOT get into the yes callback), but then send push #2 and then click on the no button - then the yes callback finally gets called.
Also - if I continue in this vein, sending additional pushes and clicking back and forth between the yes and no buttons, it only takes a handful of pushes before I get this error as well:

void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

I am using:

  • Xcode 7.2
  • IOS 9.2.1 on an Iphone 5
  • cordova cli: 6.0.0
  • cordova-ios: 4.0.1
  • phonegap-plugin-push: 1.5.3

I have my callbacks defined like:
window.acceptVerification = function(data) {
console.log('PushService: handle Accept Verification Button');
console.log("ACCEPT DATA: " + JSON.stringify(data));
}
window.rejectVerification = function(data) {
console.log('PushService: handle Reject Verification Button');
console.log("REJECT DATA: " + JSON.stringify(data));
}

and my init config looks like:
config = {
"ios" : {
"badge": "true",
"clearBadge": "true",
"sound": "true",
"alert": "true",
"categories": {
"verification": {
"yes": {
"callback": "window.acceptVerification",
"title": "Accept",
"foreground": false,
"destructive": false
},
"no": {
"callback": "window.rejectVerification",
"title": "Reject",
"foreground": false,
"destructive": true
}
}
}
}
}

@jopelkey
Copy link
Author

jopelkey commented Feb 5, 2016

In case it helps - here's a little more logging from one of my scenarios.

I send 3 pushes and on each one I hit 'Accept' (the yes button).

You can see from the logging that the push plugin gets the notification and sees the payload keys on every push, but my callbacks only get called sometimes.

On the 1st push/Accept - the push plugin logs, but I do NOT see my callback logging.
On the 2nd push/Accept - the push plugin logs, and I do see my callback logging.
On the 3rd push/Accept - I get the SendDelegateMessage failed logging, then the push plugin logs, and I do NOT see my callback logging.

1st Push logging

2016-02-05 11:02:34.623 Mobile Auth[323:29939] Push Plugin handleActionWithIdentifier window.acceptVerification
2016-02-05 11:02:34.624 Mobile Auth[323:29939] Notification received
2016-02-05 11:02:34.624 Mobile Auth[323:29939] Push Plugin key: sound
2016-02-05 11:02:34.624 Mobile Auth[323:29939] Push Plugin key: alert
2016-02-05 11:02:34.624 Mobile Auth[323:29939] Push Plugin key: category
2016-02-05 11:02:34.624 Mobile Auth[323:29939] Push Plugin key: badge

2nd Push logging

2016-02-05 11:02:52.914 Mobile Auth[323:29939] Push Plugin handleActionWithIdentifier window.acceptVerification
2016-02-05 11:02:52.914 Mobile Auth[323:29939] Notification received
2016-02-05 11:02:52.915 Mobile Auth[323:29939] Push Plugin key: sound
2016-02-05 11:02:52.915 Mobile Auth[323:29939] Push Plugin key: alert
2016-02-05 11:02:52.915 Mobile Auth[323:29939] Push Plugin key: category
2016-02-05 11:02:52.915 Mobile Auth[323:29939] Push Plugin key: badge

2016-02-05 11:03:16.190 Mobile Auth[323:29939] PushService: handle Accept Verification Button
2016-02-05 11:03:16.190 Mobile Auth[323:29939] ACCEPT DATA: {"additionalData":{"pushPayload":{"request":{"loginUri":"website.com","requestTimestamp":1454695346},"foreground":false,"category":"verification","callback":"window.acceptVerification"},"message":"some message","count":1,"sound":"default"}

3rd Push logging

2016-02-05 11:03:16.195 Mobile Auth[323:29988] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
2016-02-05 11:03:16.197 Mobile Auth[323:29939] Push Plugin handleActionWithIdentifier window.acceptVerification
2016-02-05 11:03:16.197 Mobile Auth[323:29939] Notification received
2016-02-05 11:03:16.197 Mobile Auth[323:29939] Push Plugin key: sound
2016-02-05 11:03:16.198 Mobile Auth[323:29939] Push Plugin key: alert
2016-02-05 11:03:16.198 Mobile Auth[323:29939] Push Plugin key: category
2016-02-05 11:03:16.198 Mobile Auth[323:29939] Push Plugin key: badge

@macdonst
Copy link
Member

macdonst commented Feb 8, 2016

@jopelkey this is really good information but I believe it is the same root cause as #557. When foreground is set to false the callback is not triggered until the app is opened. I'm looking into it.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants