dpa99c / cordova-plugin-firebasex

Cordova plugin for Google Firebase
MIT License
572 stars 462 forks source link

Android / iOS background message (push) #270

Closed mpawlak96 closed 4 years ago

mpawlak96 commented 4 years ago

Hello,

I have a problem / bug with push notification to iOS / Android when app is running in background. I have code (below you can see). If app is not running and i'm clicking in notification, function run correctly but when app is working in background and im clicking in notification - function wont run.

cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport" cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx" cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-console 1.1.0 "Console" cordova-plugin-customurlscheme 4.4.0 "Custom URL scheme" cordova-plugin-device 2.0.3 "Device" cordova-plugin-facebook4 6.2.0 "Facebook Connect" cordova-plugin-firebasex 7.0.1 "Google Firebase Plugin" cordova-plugin-geolocation 4.0.2 "Geolocation" cordova-plugin-globalization 1.11.0 "Globalization" cordova-plugin-googleplus 8.2.0 "Google SignIn" cordova-plugin-inappbrowser 3.1.0 "InAppBrowser" cordova-plugin-ios-location-permissions 1.2.0 "iOS Permissions" cordova-plugin-nativegeocoder 3.2.2 "NativeGeocoder" cordova-plugin-splashscreen 5.0.3 "Splashscreen" cordova-plugin-statusbar 2.4.3 "StatusBar" cordova-plugin-whitelist 1.3.4 "Whitelist" cordova-plugin-x-socialsharing 5.6.2 "SocialSharing" es6-promise-plugin 4.2.2 "Promise"

Runtime issue

Related code:


$(document).on('deviceready', onDeviceReady);

function onDeviceReady(){

    window.FirebasePlugin.onMessageReceived(function(message) {
    alert("Message type: " + message.messageType);
    if(message.messageType === "notification"){
        alert("Notification message received");
        if(message.tap){
            alert("Tapped in " + message.tap);
        }
    }
        alert(message);
    }, function(error) {
            alert(error);
    });

}
dpa99c commented 4 years ago

This is because your device is Xiaomi - certain OEMs blacklist apps from autostarting which causes this issue. This is covered by #235.