我在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();
});
}
}
}