Open iparrabb opened 7 years ago
Which is my mistake?, I'm testing the notifications but when the app is closed ONLY ON iOS doesn't work.
if($token->platform === 'ios') {
$data = [
'to' => $token->device_token,
'notification' => [
'body' => $notification_request->message,
'title' => $notification_request->title,
"content_available" => true,
],
"aps" => [
"content-available" => 1,
],
"priority" => 'high',
"data" => [
"published" => Carbon::parse($not->created_at)->format('d/m/Y H:i'),
],
'notId' => $not->id,
];
} elseif ($token->platform === 'android') {
$data = [
'to' => $token->device_token,
'data' => [
'body' => $notification_request->message,
'title' => $notification_request->title,
'icon' => 'ic_stat_airplanemode_active',
'notId' => $not->id,
"content-available" => "1",
],
"priority" => "high",
];
}
I followed the steps of #1828.
@fredgalvao @macdonst any help please?????
@iparrabb try the following for iOS:
if($token->platform === 'ios') {
$data = [
'to' => $token->device_token,
'notification' => [
'body' => $notification_request->message,
'title' => $notification_request->title
],
"content_available" => true,
"priority" => 'high',
"data" => [
"published" => Carbon::parse($not->created_at)->format('d/m/Y H:i'),
],
'notId' => $not->id,
];
}
Sending to iOS via GCM/FCM requires we follow https://developers.google.com/cloud-messaging/http-server-ref#downstream-http-messages-json and I should update the docs.
Thanks for your reply @macdonst, I can test this snippet but the result is the same.
Foreground Android and iOS ¡OK! Background Android and iOS ¡OK! App closed Android ¡OK! iOS ¡FAILED!
I tested too with APNS instead of FCM without lucky, same result.
Hi, @iparrabb i'm facing the same issue.
App closed Android ¡OK! iOS ¡FAILED!
Did you find some fix for that?
wrt https://github.com/phonegap/phonegap-plugin-push/issues/1833#issuecomment-314152890 if the app is force-killed on iOS, no notifications are delivered by the OS.
You have to use pushkit to get around that, and it is hard because pushkit is only supported for three use cases.
https://developer.apple.com/documentation/pushkit
If your app isn't running, the system automatically launches it upon receiving the notification. Although you can also use silent user notifications to update your app in the background, your app isn't guaranteed to launch when a notification arrives. For more information, see Local and Remote Notification Programming Guide.
@shankari thanks a lot, currently the app is published in the app and play stores, on the next version I need to check this behavior.
@talvespe, check the reply of shankari.
@iparrabb thanks in advance i'll check and let u know.
If a send : $resposta = shell_exec('curl -X POST --header ' . '"Authorization: key=AAAAaUS7Nr4:APA91bHj3O-F4xyGheS2Umk6ZmJBfighcGBd_VTvsih7lAvJNGWyfd5udZVv_Bqchrq6I1Iim6BFRe_IxH1UANbetVb0ojAHx6vl-v4iP-5OzXtJ3tkixSlSZqWtZO6PhIYHJo5E0cBELVlv3kVDzbAF5e_iCqE_Bw"' . ' --header' . ' "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d ' . '"{\"registration_ids\":\"' . $registrationIds . '\",' . '\"priority\":\"high\",' . '\"content-available\":\"true\",' // . '\"notification\":{\"body\": \"Teste 646\",\"title\": \"teste\", \"id_oferta\": \"646\" }}"'); . '\"data\":{\"body\": \"646\",\"title\": \"teste\", \"id_oferta\": \"646\" }}"');
The event on('notification' is OK !
If a use: $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, $fields );
not fired.
if a use: $resposta = shell_exec('curl -X POST --header ' . '"Authorization: key=AAAAaUS7Nr4:APA91bHj3O-F4xyGheS2Umk6ZmJBfighcGBd_VTvsih7lAvJNGWyfd5udZVv_Bqchrq6I1Iim6BFRe_IxH1UANbetVb0ojAHx6vl-v4iP-5OzXtJ3tkixSlSZqWtZO6PhIYHJo5E0cBELVlv3kVDzbAF5e_iCqE_Bw"' . ' --header' . ' "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d ' . '"{\"registration_ids\":\"' . $registrationIds . '\",' . '\"priority\":\"high\",' . '\"content-available\":\"true\",' . '\"notification\":{\"body\": \"Teste 646\",\"title\": \"teste\", \"id_oferta\": \"646\" }}"'); // . '\"data\":{\"body\": \"646\",\"title\": \"teste\", \"id_oferta\": \"646\" }}"'); not fired to
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Expected Behaviour
"on('notification')" event is triggered on background mode
Actual Behaviour
"on('notification')" event is triggered only when app is in foreground or when app received a notification and user clicked it.
Reproduce Scenario
[Only on iOS] The app works with Ionic 2 and FCM on Android and iOS, but when a notification is received, if you click on it, the app launches and notification plugin triggers the "on('notification')" event. But if you just runs the app, after receiving a notification, the event doesn't trigger.
I have read the information about the payload but it does not work.
Platform and Version
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload
Sample Code that illustrates the problem
Logs taken while reproducing problem
Logs not working when app is in background.
Thanks.