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

App not opening when click on push. #205

Open
mrlennartsson opened this issue Oct 14, 2022 · 3 comments
Open

App not opening when click on push. #205

mrlennartsson opened this issue Oct 14, 2022 · 3 comments

Comments

@mrlennartsson
Copy link

Bug Report

Expected Behaviour

When i get a push from the app, and click on the message the app should start.

Actual Behaviour

The app doesnt start. Looks like it's starting in the background.

Im using:
@havesource/cordova-plugin-push 4.0.0-dev.0

@havesource/cordova-plugin-push 4.0.0-dev.0 "Cordova Push Plugin"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-inappbrowser 5.0.0 "InAppBrowser"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.5 "Whitelist"

@Mister-CK
Copy link

Are you having these issues on iOS or android?
Which version of the plugin are you using?
is the app already running in the background?

@TinerfeV
Copy link

I have the same problem.

It happens in Android 12 and Android 13.

Tested plugin version: 3.0.1 and 4.0.0-dev.0

My JS Code:

document.addEventListener('deviceready', onDeviceReady, false);
document.addEventListener('resume', onDeviceReady, false);

function onDeviceReady() {

const push = PushNotification.init({
	android: {
	},
	ios: {
		alert: "true",
		badge: "true",
		sound: "true",
		clearBadge: "true"
	}
});

push.on('registration', (data) => {
	document.getElementById("regId").value = data.registrationId;
});

push.on('notification', (data) => {
	//console.log(data.message);
	//console.log(data.title);
	//console.log(data.count);
	//console.log(data.sound);
	//console.log(data.image);
	//console.log(data.additionalData);
});

push.on('error', (e) => {
	// e.message
});

document.addEventListener("backbutton", onBackKeyDown, false);
// Cordova is now initialized. Have fun!
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);

}

@TinerfeV
Copy link

I found a solution that worked, at least in my case. Simply commenting out the 'click_action' in the .php file that sends the notification:

$message = array(
'title' => $nombreCole,
'body' => $message,
'icon' => 'fcm_push_icon',
'color' => $color,
'badge' => '1',
'sound' => 'default'
//'click_action' => 'FCM_PLUGIN_ACTIVITY'
);

In this link you can see how the structure for this plugin has to be created:
https://github.com/havesource/cordova-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants