ionic 2 error cordova not available

后端 未结 5 1945
Happy的楠姐
Happy的楠姐 2020-12-03 02:57

I am trying to use the cordova GooglePlus plugin in a new ionic 2 project (latest ionic2 version) but I always run into errors regarding cordova. The plugin is properly inst

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 03:17

    Sometimes using ionic cordova run browser is not the best option, since it takes a long time for it to compile your changes.

    In my case, what was causing the issue was the FCM plugin. It cannot run on the browser, if I use ionic serve. Since my code was inside app.component.ts, it was easy for me to get around the problem. I simply used the following line:

      if (platform.is('cordova')) 
         {  this.fcmx.onTokenRefresh().subscribe(token => { 
         this.pushNoti.storeNewToken(token); }); }
    

    Using platform.is('cordova'), you can prevent the code causing trouble to run on the browser.

提交回复
热议问题