bsorrentino / cordova-broadcaster

Cordova Plugin to allow message exchange between javascript and native (and viceversa)
MIT License
113 stars 53 forks source link

ionic app can't exit after adding listener #7

Closed paololabe closed 7 years ago

paololabe commented 8 years ago

Ho notato che dopo aver utilizzato:

window.broadcaster.addEventListener("configChanged", function (e) {
  console.log( "configChanged received! userInfo: ", e  );
  $rootScope.$broadcast('configChanged', e);
});

l'applicazione cordova/ionic non riesce più ad uscire con il tasto back hardware ne con un comando esplicito exitApp. Ho provato ad richiamare removeEventListener, ma niente da fare.

Hai qualche idea ?

Grazie.

bsorrentino commented 7 years ago

Ciao

Scusa per il ritardo nella risposta ma avevo un problema sulle notifiche che ignoravo

Hai ancora il problema che mi hai segnalato ? Se si su quale versione di ionic lo hai riscontrato ?

Una "best practice" sarebbe quella di evitare lunge operazioni sincrone all'interno del listener che è gestito dall'infrastruttura cordova. Non conosco in dettaglio ionic ma, giusto per fare un test, magari prova ad usare un timer

mebibou commented 7 years ago

Actually I have the same issue, if I use your plugin the back button has no more effect, the app just won't exit. I tried to call manually removeEventListener but to no avail

bsorrentino commented 7 years ago

Hi thanks for feedback

In order to efficiently perform tests, could you provide me your mobile platform details ?

mebibou commented 7 years ago

I have just tried with Genymotion emulator on 4.4.4 and it doesnt work either. I've built a simple ionic app to demonstrate the problem

bsorrentino commented 7 years ago

Hi, thanks for your sample

I've tested it and confirm (unfortunately) that back button does't work

I've done a lot of tests ... also removing native code implementation ... but seems that just a cordova exec call triggers the bug

I'll continue to going in deep to better understand the cordova & ionic interactions .. and I'll report results on this issue

mebibou commented 7 years ago

yeah I didn't play around with your plugin but others do work fine, like the call here to the Splashscreen plugin that does a cordova exec as well works fine, so maybe it's how you handle it? idk, thanks for looking at it

bsorrentino commented 7 years ago

I noted that at application startup appear the following message:

WARNING: Back Button Default Behavior will be overridden. The backbutton event will be fired!

Such message is logged by method org.apache.cordova.CoreAndroid.overrideBackbutton(boolean override);

I'm investigating on who calls it.

bsorrentino commented 7 years ago

Finally I got it

The problem was related to onMessage overriding that inhibited the passage of system messages

I've released the version 2.1.0 with fix