Reference error after app resumes :(

Hi folks,
Im trying to tackle an nasty bug in one of your ionic applications.
The whole application works as intended UNTIL we plug the device into the docking station!
This triggers the whole app to “reload” (pause -> resume i think) while showing the spashscreen again.
After the splash screen vanishes the page stays blank.
Trying to reproduce it in debug mode reveals:
One plugin (cordova-plugin-fastrde-mqtt) is somehow undefined and throws an ReferenceError.

Currently i do not have ANY clue how to tackle this. Can you give me an idea where to look or how to prevent this behavior?

Does this mean you don’t have control of the source code? Whose application is this?

Hi Aaron,
Sorry for the confusion.
I DO have control over the source code.
When we launch the app and work with it (even when sending it to sleep by opening other apps) everything works smooth and easy.
Except when we dock it into the docking station! Then the mqtt plugin gets lost.

And now i have no idea WHY that could happen.


Would the same thing happen with a different plugin, or a mock? I ask because there are two main ways this can occur: (1) it’s an issue with your code, or (2) it’s an issue with the plugin’s code. There is of course possibility (3): it’s an issue with Ionic’s code. But since your problem is unusual, I think it’s safe to focus on (1) or (2) for now.

My point: if you mock it out with a function that does nothing, do you still get the same reference error?

I think it’s no bug in ionic, too.
The problem is: the cordova-plugin-fastrde-mqtt doesn’t get included by a provider.
So the only thing we do in the code is declare var mqtt: any;
That works the whole time except when docking the device.

Is there any way to disable the docking mode? Cause when docking the device in the logcat says that the ionic app gets restarted (stop -> resume -> destroy -> create). Somewhere the plugin gets lost… :frowning:

I don’t know the answer to your question, but could you just register the declare in a tiny provider? Then you register the provider in app.module.ts, and maybe the app is always happy.

Edit: It also occurs to me that, depending on what you do with the plugin, you might want to write an Ionic Native shim for it.