Cordova-Plugin-Firebase, when the application switches from OFF to ACTIVE, onNotificationOpen () does not work on Android

I implemented Cordova-Plugin-Firebase in an Ionic2 project on an Android device.

I followed the recommendations and it works. About the onNotificationOpen () function, as explained in the plugin doc :

The application is in the background:

  • The user receives a notification message in the notification panel of his device

  • User deletes notification and application opens

  • User receives notification data in javascript callback

If the application is closed (not in the background), if I send Push Notification, it does the following:

  • The user receives a notification in the notification line of his device

, , .

, , :

Firebase.onNotificationOpen().subscribe(
       (res) => { console.info(res)},
       (err) => { console.info(err)},
       () => {console.log("completed)}
);

, , , , , . , , , .

: , , -; , , OFF ACTIVE? , , ?

+4
1

Push- (, deeplink) - . - , . , Firebase, .

, push- Intent . , (, onStart/Resume()). , , , , - :

Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.my.package cmp=com.my.package/.MyMainActivity (has extras) }
Extras { 
   google.sent_time > 1490275998196, 
   from > 9994599943, 
   google.message_id > 0:14902799999965%346177c211bbbb7c2, 
   collapse_key > com.my.package 
}

, -

if (getIntent() != null && getIntent().getExtras() != null) {
    //identify whether this was a push notification intent
    if (getIntent().getExtras().get("google.message_id") != null) { 
        //Here you can do the same things you do when opened from background
        console.log("completed"");
    }
}
0

Source: https://habr.com/ru/post/1672288/


All Articles