【发布时间】:2019-11-16 23:56:24
【问题描述】:
我一步一步跟着这个教程https://ionicthemes.com/tutorials/about/ionic-facebook-login
我遇到的问题是登录后,我的应用程序没有重定向到我需要它的页面。在运行 Android 9 的模拟 Pixel 2 设备上进行测试时,控制台上没有错误。以下是处理身份验证的代码:
const permissions = ['public_profile', 'email'];
await this.facebook.login(permissions).then(response => {
this.uid = response.authResponse.userID;
this.facebook.api('/me?fields=name,email', permissions)
.then(user => {
user.picture = 'https://graph.facebook.com/' + userId +
'/picture?type=large';
this.dataService.getUser(this.uid).subscribe((data) => {
if (data.data() !== undefined) {
if (data.data().isNew) {
this.zone.run(() => {
this.router.navigate(['/profile']);
});
} else {
this.zone.run(() => {
this.router.navigate(['/home']);
});
}
} else {
this.dataService.addUser(....)}).then(() => {
this.zone.run(() => {
this.router.navigate(['/profile']);
});
}
});
});
我希望在登录成功后,应用程序会使用路由器角度组件正确重定向。
【问题讨论】:
标签: android facebook cordova ionic-framework ionic4