Check if App is Using DevAPP

I’m trying to figure out how to check if my app is running on DevAPP.
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.

Bake your own DevApp with the plugins you want

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.fcm.getToken().then( token => {
    console.log( 'token: ', token ); //@DEBUG
.catch( error => { // Catch error that FCM is not available in DevAPP and web
    console.log( 'Error Getting FCM Token: ', error ); //@DEBUG

This can also work with Observables by processing the error response option:

    data => {
        console.log( 'data: ', data ); //@DEBUG
    error => {
        console.log( 'Error Subscribing to FCM Notification: ', error ); //@DEBUG

After implementing this code, my app no longer crashed while running in DevAPP.

1 Like