I’m trying to figure out how to check if my Ionic app is running on DevAPP (DevAPP is a testing platform that runs your app locally on your device).
This is important because I’m using a plugin that is not available in DevAPP, so it crashes the app. I want to be able to perform some kind of check to see if the app is being run with DevAPP. And, if it is, I just won’t call the code for the unavailable plugin.
I’ve tried checking platform.platforms()
, but it just says “mobile,android,phablet,mobileweb”. Those don’t seem to suggest that DevAPP is running.
Another possible solution would be a way to check if a plugin is installed. I tried just checking if the injected variable was truthy if( this.fcm )
, but this still crashes the app.
All right. Well, I wasn't able to figure out how to specifically check within the code whether or not the app is currently running on DevAPP. But I did manage to find a solution to my problem. It was actually pretty straight-forward.
Since the native plugin I was trying to use returns a promise, I just used the .catch() method available on promises:
This can also work with Observables by processing the error response option:
After implementing this code, my app no longer crashed while running in DevAPP.