arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1.01k stars 1.56k forks source link

Uncaught TypeError: window.FirebasePlugin.initFirebase is not a function #1064

Open girishk55 opened 5 years ago

girishk55 commented 5 years ago

Describe the bug Uncaught TypeError: window.FirebasePlugin.initFirebase is not a function error on Android platform

Expected behavior It should initialise and give instance id.

Console Logs Uncaught TypeError: window.FirebasePlugin.initFirebase is not a function

Plugin Version latest 2.0.5. also tried 1.0.5.

FrancescoPaiola commented 5 years ago

do you use Ionic Framework? Can you provide some code?

girishk55 commented 5 years ago

I use Cordova. Below is the source code -

    window.FirebasePlugin.initFirebase()

    if (device.platform == "iOS") {
        window.FirebasePlugin.grantPermission();
    }
    window.FirebasePlugin.setBadgeNumber(0);

    // Handle notifications through firebase
    // Get the device token (id):
    // Note that token will be null if it has not been established yet
    window.FirebasePlugin.getToken(function (token) {
            console.log('Device Token: ' + token);
    }, function (error) {
            console.error('Device Token Error: ' + error);
    });

    //This is the best way to get a valid token for the device as soon as the token is established
    //Register notification callback:
    window.FirebasePlugin.onNotificationOpen(function (notification) {
        console.log('notification details: '+ JSON.stringify(notification));
    },
    function (error) {
            console.error(error);
    });