I’m working on an old Ionic application using Cordova and i am trying to have Login with Facebook, specifically with the cordova-plugin-facebook-connect plugin. The login process seems to work, but after a successful login, the app redirects back to the sign-in screen, and taps within the app become unresponsive.
Environment: Ionic Framework: 7.2.0, Cordova: 12.0.0 ([email protected]), cordova-plugin-facebook-connect": "^3.2.0,
Package.json : "cordova-plugin-facebook-connect": { "APP_ID": ".....", "APP_NAME": "...", "FACEBOOK_URL_SCHEME_SUFFIX": " ", "OTHER_APP_SCHEMES": " ", "FACEBOOK_AUTO_LOG_APP_EVENTS": "true", "FACEBOOK_HYBRID_APP_EVENTS": "false", "FACEBOOK_ADVERTISER_ID_COLLECTION": "true", "FACEBOOK_ANDROID_SDK_VERSION": "14.1.0", "FACEBOOK_IOS_SDK_VERSION": "11.1.0", "FACEBOOK_BROWSER_SDK_VERSION": "v11.0" }
Code :
async fbLogin() {
try {
if (this.platform.is("cordova")) {
const response = await this.fb.login(["public_profile", "email"]);
if (response.status === "connected") {
console.error("Facebook login Succeed");
this.isLoggedIn = true;
this.getFBUserDetail(res.authResponse.userID);
} else {
console.error("Facebook login failed:", response);
this.isLoggedIn = false;
}
} else {
console.error("Facebook login is only available on device");
}
} catch (error) {
console.error("Error during Facebook login:", error);
}
}
a
nd
getFBUserDetail(userid: any) {
this.fb
.api(
"/" + userid + "/?fields=id,email,name,first_name,last_name,picture",
["public_profile"]
)
.then((res) => {
this.users = res;
let formData = {
customer_name: this.users.first_name,
customer_lastname: this.users.last_name,
customer_email: this.users.email,
fb_id: this.users.id,
image: this.users.picture.data.url,
};
this.loaderService.show("PLEASE_WAIT");
this.api.post("fb_login", formData).subscribe(
(res: any) => {
this.loaderService.hideAll();
this.storage.set("USER_ID", res.response.customer_id);
this.storage.set("USER_NAME", this.users.first_name + " " + this.users.last_name);
this.storage.set("USER_IMAGE", this.users.picture.data.url);
this.storage.set("USER_EMAIL", this.users.email);
this.storage.set("USER_REFERRAL_CODE", res.response.refer_code);
this.storage.set("USER_DETAILS", res.response);
this.GlobalobservablesService.publishData({ APP_NAME: "order_status" });
this.loaderService.showToast(this.translate.instant("LOGIN_SUCCESS"));
setTimeout(() => {
this.route.navigate(["./home"]);
});
},
(err) => {
this.loaderService.hideAll();
}
);
})
.catch((e) => {
console.error("Error during getting Facebook details:", e);
});
}
Issue Summary: After a successful Facebook login, the app redirects back to the sign-in screen. Taps and interactions become unresponsive. No logs or errors appear after the login attempt in Chrome DevTools.
Additional Details: I commented out AppEventsLogger.deactivateApp(cordova.getActivity().getApplication()); in ConnectPlugin.java because it caused build failures.