{"action":"created","issue":{"url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/822","repository_url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase","labels_url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/822/labels{/name}","comments_url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/822/comments","events_url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/822/events","html_url":"https://github.com/arnesson/cordova-plugin-firebase/issues/822","id":356898423,"node_id":"MDU6SXNzdWUzNTY4OTg0MjM=","number":822,"title":"Can't use initFirebase() on 1.1.3 [Firebase isn't initialised] [Solutions proposed]","user":{"login":"BrainOverflown","id":42948359,"node_id":"MDQ6VXNlcjQyOTQ4MzU5","avatar_url":"https://avatars2.githubusercontent.com/u/42948359?v=4","gravatar_id":"","url":"https://api.github.com/users/BrainOverflown","html_url":"https://github.com/BrainOverflown","followers_url":"https://api.github.com/users/BrainOverflown/followers","following_url":"https://api.github.com/users/BrainOverflown/following{/other_user}","gists_url":"https://api.github.com/users/BrainOverflown/gists{/gist_id}","starred_url":"https://api.github.com/users/BrainOverflown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrainOverflown/subscriptions","organizations_url":"https://api.github.com/users/BrainOverflown/orgs","repos_url":"https://api.github.com/users/BrainOverflown/repos","events_url":"https://api.github.com/users/BrainOverflown/events{/privacy}","received_events_url":"https://api.github.com/users/BrainOverflown/received_events","type":"User","site_admin":false},"labels":[{"id":1039885597,"node_id":"MDU6TGFiZWwxMDM5ODg1NTk3","url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/labels/bug:%20build","name":"bug: build","color":"ee0701","default":false},{"id":391682361,"node_id":"MDU6TGFiZWwzOTE2ODIzNjE=","url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true},{"id":391682363,"node_id":"MDU6TGFiZWwzOTE2ODIzNjM=","url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":23,"created_at":"2018-09-04T17:04:20Z","updated_at":"2018-09-07T15:19:12Z","closed_at":null,"author_association":"NONE","body":"I just updated cordova-plugin-firebase to 1.1.3 and tried to use the `initFirebase()` method to get rid of the 'Firebase isn't initiali**s**ed' error (note that the error got a typo in console log).\r\n\r\nI'm getting the following error : \r\n`Uncaught (in promise): TypeError: _this.firebase.initFirebase is not a function\r\nTypeError: _this.firebase.initFirebase is not a function`\r\n\r\nmy code : (note that this code [without initFirebase()] is totally working on another computer.  \r\n`import {Firebase} from \"@ionic-native/firebase\";\r\n  public start() {\r\n    return this.platform.ready().then(() => {\r\n\t  this.firebase.initFirebase();\r\n      this.firebase.getToken().then(token => {\r\n          console.log(token)\r\n          this.api.post('tg.php', {token}).subscribe(() => {\r\n          });\r\n        }\r\n      ).catch(err => console.log(err));\r\n    });\r\n  }\r\n`\r\n\r\n\r\n\r\n***** EDIT ***** : \r\n\r\n\r\n\r\n**For those encountering the same problem, here is a walkthrough which seems to help most people :** \r\n\r\n- downgrading cordova-plugin-firebase to 0.1.18 which can be done like this : \r\n`cordova plugin rm cordova-plugin-firebase`\r\n`cordova plugin add cordova-plugin-firebase@0.1.18`\r\n`npm install --save @ionic-native/firebase`\r\n\r\n**if it doesn't work** \r\n\r\n- uninstalling and reinstalling the plugin with `cordova plugin add cordova-plugin-firebase@1.0.5` then `npm install @ionic-native/firebase --save`\r\n\r\n**if it doesn't work** \r\n\r\n- try upgrading to 1.1.3 for @DomCostantino's trick : \r\n \r\n `declare var FirebasePlugin : any;`\r\n\r\n> and then insert the cordova script include in your index.html file\r\n\r\n`<script type=\"text/javascript\" src=\"cordova.js\"></script>`\r\n\r\n> and using the plugin like this:\r\n\r\n`FirebasePlugin.initFirebase();`\r\n\r\nFor those needing a practical example of how to insert it in your own code, here is a snippet courtesy of @tgensol  : \r\n\r\n`observableFromEvent(document, 'deviceready').pipe(first()).subscribe(() => {`\r\n`FirebasePlugin.initFirebase();`\r\n`FirebasePlugin.initAnalytics();`\r\n`})`\r\n\r\nDepending on how you coded your application, this may have to go in your home.ts /or/ typescript associated with the page calling it /or/ in the provider calling for the getToken() functio.\r\n\r\n\r\nIf the problem isn't solved with this step by step, write down the encountered problems here so we can help troubleshoot for you and others.\r\n\r\n[**important note** : _for people having a hard time downgrading, try deleting manually plugins and platforms folders (after backuping them/!\\), then after plugin installation go for a_ : `cordova platform add android`]\r\n\r\nGood luck \r\n\r\n(follow the thread for credits of contributors)"},"comment":{"url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/comments/419473224","html_url":"https://github.com/arnesson/cordova-plugin-firebase/issues/822#issuecomment-419473224","issue_url":"https://api.github.com/repos/arnesson/cordova-plugin-firebase/issues/822","id":419473224,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTQ3MzIyNA==","user":{"login":"aetchegoyen","id":513223,"node_id":"MDQ6VXNlcjUxMzIyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/513223?v=4","gravatar_id":"","url":"https://api.github.com/users/aetchegoyen","html_url":"https://github.com/aetchegoyen","followers_url":"https://api.github.com/users/aetchegoyen/followers","following_url":"https://api.github.com/users/aetchegoyen/following{/other_user}","gists_url":"https://api.github.com/users/aetchegoyen/gists{/gist_id}","starred_url":"https://api.github.com/users/aetchegoyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aetchegoyen/subscriptions","organizations_url":"https://api.github.com/users/aetchegoyen/orgs","repos_url":"https://api.github.com/users/aetchegoyen/repos","events_url":"https://api.github.com/users/aetchegoyen/events{/privacy}","received_events_url":"https://api.github.com/users/aetchegoyen/received_events","type":"User","site_admin":false},"created_at":"2018-09-07T15:19:12Z","updated_at":"2018-09-07T15:19:12Z","author_association":"NONE","body":"Guys, confirmed. \r\nUsing Cordova 8, Cordova Android 7.1.1 and Cordova Plugin Firebase 1.1.3:\r\n\r\nYou just need to add the  FirebasePlugin.initFirebase method before using Firebase. And then in it's success callback get your token:\r\n\r\nIE:\r\n\r\n`\r\n//Inits Firebase\r\nFirebasePlugin.initFirebase(\r\n    function(){\r\n        //Subscribes for token refresh event\r\n        window.FirebasePlugin.onTokenRefresh(\r\n            function(token) {\r\n                console.log(\"Device token refresh: \" + token);\r\n                //Your token handling functions\r\n            }, \r\n            function(error) {\r\n                console.error(\"Firebase error: \" + error);\r\n            }\r\n        );\r\n    }, \r\n    function(error) {\r\n        console.error(\"Firebase error: \" + error);\r\n    }\r\n);\r\n`"}}
{"actor":{"display_login":"aetchegoyen"}}