Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tapping notification does not move the app to foreground (Android) #589

Closed
LKruglov opened this issue Mar 7, 2018 · 4 comments
Closed

Comments

@LKruglov
Copy link

LKruglov commented Mar 7, 2018

I open my app, put it in background by pressing home button and send a notification (via this service). The notification is received and is shown in the statusbar. But nothing happens when I tap on the notification - I get back to home screen and the app is not shown.

If the app is in foreground, 'onNotificationOpen' callback works as expected and I can see notification object.

The code (called inside 'deviceready' handler):

    window.FirebasePlugin.onTokenRefresh(function(token) {
       console.log('FirebasePlugin onTokenRefresh - token:', token);
    }, console.log);
    window.FirebasePlugin.onNotificationOpen(function(notification) {
        console.log('FirebasePlugin onNotificationOpen - notification:', notification);
    }, console.log);

cordova: 8.0.0
cordova android: 6.4.0
device: HTC 10 with Android 7.0

plugin list:
cordova-plugin-battery-status 1.2.5 "Battery"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-contacts 2.3.1 "Contacts"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-device-motion 1.2.5 "Device Motion"
cordova-plugin-device-orientation 1.0.7 "Device Orientation"
cordova-plugin-dialogs 1.3.4 "Notification"
cordova-plugin-directions 0.4.4 "Directions"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-firebase 0.1.25 "Google Firebase Plugin"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-globalization 1.0.9 "Globalization"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-media 3.0.1 "Media"
cordova-plugin-media-capture 1.4.3 "Capture"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-vibration 2.1.6 "Vibration"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.3.2 "SocialSharing"
cordova-push-notifications 1.2.4 "Push Notifications Plugin"
cordova-social-vk 1.0.5 "SocialVk"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"

@LKruglov
Copy link
Author

LKruglov commented Mar 7, 2018

And if I use plugin cordova-push-notifications, the app is successfully opened after tapping the notification.

@LKruglov LKruglov changed the title Tapping notification not moving the app to foreground (Android) Tapping notification does not move the app to foreground (Android) Mar 7, 2018
@agil-NUBBA
Copy link

Seems like a duplicate of #564

@jyk20000
Copy link

Oh well.

What I had to do was to change payload format.
Other suggested removing "notification" entirely and move title and body inside data.
But it caused same issue - tapping not open app - on iOS.

I guess click_action => FCM_PLUGIN_ACTIVITY is causing problem.
To be safe, I removed all others except title and body from notification.

BEFORE

$data = json_encode([
"notification" => [
"title" => $title,
"body" => $msg,
"sound" => "default",
"click_action" => "FCM_PLUGIN_ACTIVITY"//,
"icon" => "fcm_push_icon"
],
"data" => [
"payload" => $payload
],
"to" => $device_token,
"priority" => "high",
"restricted_package_name" => ""
]);

AFTER

$data = json_encode([
"notification" => [
"title" => $title,
"body" => $msg//,
//"sound" => "default",
//"click_action" => "FCM_PLUGIN_ACTIVITY"//,
//"icon" => "fcm_push_icon"
],
"data" => [
"payload" => $payload
],
"to" => $device_token,
"priority" => "high",
"restricted_package_name" => ""
]);

@soumak77
Copy link
Contributor

soumak77 commented May 2, 2018

closing as resolved

@soumak77 soumak77 closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants