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

Android action button callback not triggered #298

Closed
stewartmegaw opened this issue Nov 3, 2015 · 6 comments
Closed

Android action button callback not triggered #298

stewartmegaw opened this issue Nov 3, 2015 · 6 comments
Labels

Comments

@stewartmegaw
Copy link

Firstly, great plugin. Much improved over the last.

When receiving a push notification with one action button:
The icon and title both display in the notification but when I click the action button (not main body of notification) two unexpected results occur:

  1. The action callback is ignored and the regular notification callback is triggered.

  2. The notification remains in the shade even though the app is now in the foreground.

  3. I have clearly defined my callback function so can't see any problems there.

  4. The notification in shade eventually disappears if I either place the app in background or click the notification again.

Tested using latest plugin 1.4.1
Android 5.0 ZenPhone 2

@macdonst macdonst added the retest label Nov 3, 2015
@macdonst
Copy link
Member

macdonst commented Nov 3, 2015

@stewartmegaw can you post the payload you are sending from GCM to the device so I can test?

@stewartmegaw
Copy link
Author

{
"registration_ids": ["fOrCjNuH4tg:APA91bEazxEGrgZbWWakr9VrNzWh-AwZcX6bNCTlaWiz5KQ4ZeVdQbTPYnCHiziWFTQTkahwtyh7FVU-aUgEFmW-QvrYrjruGw_r0AmF7Q-2oVxKdiE1cX3hhfajihqnxT79zaVdm0Lj"],
"data": {
"id": 100042,
"type": "New trip",
"message": "Charlie Fall planned a trip to Fiji",
"title": "New trip",
"deep_link": "notif_type%3Dfriend_new_trip%26user_from%3D3893582%26identifier%3Dsolr_3893582_5639604a95a9f%26accommodation%3D1",
"actions": [{
"icon": "accomm",
"title": "OFFER ACCOMMODATION",
"callback": "proa"
}]
}
}

This is the json my php script is sending to GCM via the following curl commands:
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
$result = curl_exec($ch);

These commands do send the notification. And I can't see a problem with the json above (fyi i logged it as a string using json_encode function). And function proa is declared globally in my index.html.

@bau720123
Copy link

hi @macdonst
I have the same problem (1.4.2 version)
I use php to send a notification to GCM and I really receive a notification in my phone (Android 4.4.2)
I also according to this
#274
use "window.callbackName" to instead
but still not work

here is my php payload

$fields = array('registration_ids' => 'my registration_id', 
 'data' => array(
 'title' => 'my title'
 'message' => 'the message',
 'style' => 'inbox', 
 'summaryText' => 'here have %n% messages', 
 'actions' => array(array('icon' => 'emailGuests','title' => 'bottom1','callback' => 'window.actions_left'), array('icon' => 'snooze','title' => 'bottom2','callback' => 'window.actions_right')),
 'image' => 'the image http url',
 'notId' =>'the notid', 
 'payload' => 'the others'
 )
 );

here is my javascript

push.on('registration', function(data)
{
//will trigger
});

push.on('notification', function(data)
{
//will trigger
});

window.actions_left = function(data) 
{ 
alert("left:" + data); //not trigger
};

window.actions_center = function(data) 
{ 
alert("center:" + data); //not trigger
};

window.actions_right = function(data) 
{ 
alert("right:" + data);
};

here is my screenshot
screenshot_2015-11-04-14-22-00

@bau720123
Copy link

solve in
#274

@macdonst macdonst closed this as completed Dec 7, 2015
@sumeeranalabs
Copy link

hi bau720123,
can u expalined me in detailed?i am stuck here from a week on callback function.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

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

No branches or pull requests

4 participants