Search code examples
ionic2facebook-oauth

"__zone_symbol_currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0}}


I am getting this error

"__zone_symbol_currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0}}

while login facebook from my hybrid application. I have used

ng2-cordova-oauth

plugin to achieve facebook login. My code look like.

import { Component } from '@angular/core';
import {IonicPage, NavController, Platform} from 'ionic-angular';
import {OauthCordova} from '../../../node_modules/ng2-cordova-oauth/platform/cordova';
import {Facebook} from '../../../node_modules/ng2-cordova-oauth/core';

@IonicPage()
@Component({
  selector: 'page-facebook',
  templateUrl: 'facebook.html',
})
export class FacebookPage {

  public oauth: OauthCordova;
  private provider: Facebook;

  public constructor(public navCtrl: NavController, private platform: Platform) {
    this.oauth = new OauthCordova();
    this.provider = new Facebook({
      clientId: "1807864452579635",
      appScope: ['id','story','picture','link','type','full_picture','message']
    });
  }

  public login() {
    this.platform.ready().then(() => {
      this.oauth.logInVia(this.provider).then((success) => {
        alert(JSON.stringify(success));
      }, (error) => {
        console.log(JSON.stringify(error));
      });
    });
  }

}

Solution

  • I ran into this on a project I was working on too. The problem turned out to be that the ng2-cordova-oauth dependencies weren't installed. Specifically we had to run:

    • cordova plugin add cordova-plugin-inappbrowser
    • cordova plugin add cordova-plugin-whitelist
    • cordova prepare

    You may also have to whitelist your site using the information found at https://github.com/apache/cordova-plugin-whitelist

    Edit: You can't use ng2-cordova-oauth from the browser. You have to use a device or a simulator.