Cordova-plugin-firebase: window.FirebasePlugin undefined

Created on 5 Jul 2016  路  10Comments  路  Source: arnesson/cordova-plugin-firebase

No matter what I try to do or how long I wait, I get window.FirebasePlugin undefined on iOS

My app is using Ionic and I have impletemented $ionicPlatform.ready(function() { }) to wait until cordova is loaded before trying to execute window.FirebasePlugin.getInstanceId(), but every time I do I receive the undefined error message.

Any ideas?

Most helpful comment

I finally realised that my problem was that I was importing Cordova.js too late in my app. Making it the first script to load fixed things for me.

All 10 comments

Just for clarification, have you gotten it to work on Android and it's only iOS giving issues, or have you only tested on iOS? Also, do you have other plugins installed that are not showing as undefined?

I got the same problem, but in my case it's on android. At first I got UNEXPECTED TOP-LEVEL EXCEPTION when build, I edit build.gradle in platforms/android and add :

configurations {
all_.exclude group: 'com.android.support', module: 'support-v4'
all_.exclude group: 'com.google.android.gms', module: 'play-services'
}

and it works (auto collect data is collected at my firebase page), but window.FirebasePlugin is undefined, so I can't trigger any other event. Can you help me?

Sorry Troy, I didn't see your message until now. I have not tested on Android, and I am using many other plugins without issue.

I'm facing the same issue window.FirebasePlugin undefined
Im using android cordova.
Any solution for this issue?

In my case, window.FirebasePlugin not return undefined when called in deviceready or after deviceready triggered. I got undefined when I called it in $(document).ready()

you can't call FirebasePlugin before deviceready has been triggered

I still have this issue. I am definitely only calling logEvent after deviceready has been triggered, but FirebasePlugin is still undefined.

hello for android it had failed but this worked for me.

as Robert said " you can't call FirebasePlugin before deviceready has been triggered"

var token_id = document.getElementById("token_id");

document.addEventListener('deviceready', DeviceReady, false);

function DeviceReady(){
    window.FirebasePlugin.getToken(function(token) {
        // save this server-side and use it to push notifications to this device
        console.log(token);
        token_id.innerHTML = "the token is "+ token;
    }, function(error) {
        console.error(error);
        token_id.innerHTML = "the token error  "+ error;
    });
}

I finally realised that my problem was that I was importing Cordova.js too late in my app. Making it the first script to load fixed things for me.

If you have the plugin installed(cordova-plugin-firebase). Try removing and reinstalling again. That's the only thing that worked for me.

PS: I was having issue with iOS.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LKruglov picture LKruglov  路  4Comments

rlz picture rlz  路  4Comments

Zrnik picture Zrnik  路  3Comments

JonSmart picture JonSmart  路  3Comments

rolinger picture rolinger  路  5Comments