ngx-facebook npm软件包的ui mathod承诺永远不会解决或拒绝

时间:2018-12-12 06:09:10

标签: typescript angular6

我在Angular 6项目中使用ngx-facebook包登录并共享到Facebook。登录工作正常,但是当我要在Facebook中分享信息时,成功分享后ui弹出窗口不会关闭。我检查了问题,并在.then()或.catch()中得到了该回调从未调用过的方法。这是我的代码-

export class MyClass(){
  constructor(
     @Inject(WINDOW) private window: Window,
    private fb: FacebookService, 
 ) {
    const initParams: InitParams = {
      status: true,
      cookie: true,
      xfbml: true,
      version: 'v2.10'
    };
    fb.init(initParams);
  }
  shareOnFb(options : any) {
    return new Promise((resolve, reject) => {
      const newOption: UIParams = {
        method: 'share',
        href: options.href,
        redirect_uri: 'https://myUrl.com/404#confirm'
      };
      this.fb.ui(newOption)
      .then((res: UIResponse) => {
        if (res.error_message) {
          this.toastrService.error('failed');
          reject();
        } else {
          resolve(true);
        }
      }).catch((e : any) => {
          reject();
      });
    }
}
}

0 个答案:

没有答案
相关问题