New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session is always null in getLoginStatus #499
Comments
Same problem over here... Any solutions? |
Ok, I fixed this. I just didn't close the issue because I think that it is still a bug (or there is something I don't understando on the sequence. I went to ConnectPlugin.java, on facebook plugin, and change this piece of code on "initialize" method.
by this one
As you can notice, it's only one line that I moved up....still can't understand which one is the expected behavior of the developer if your first action after plugin initialization is "getLoginStatus" |
Thank you! |
@sonoman Thanks! This fixed my issue as well. |
👍 @sonoman Thanks it solved the issue in our app too ! |
Now, for some weird reason, after calling the facebookConnectPlugin.login(["basic_info", "email"],fb.loginSuccess,fb.loginFail); I get no response. i Can get status but, when trying to login, it does not work. My app calls FB APP, which prompts the user to allow me or not to get basic_info and email, and after the user choose, android resumes my app but neither fail nor success js functions from facebookConnectPlugin.login are triggered... Did any of you had this issue? I've installed and reinstalled the pg.fb.plugin, master and develop branch, updated cordova, rm and add android platform, cleaned ant and android builds... Out of clues here... the only response i get when my app is resumed is
And, as found in http://mail-archives.apache.org/mod_mbox/cordova-commits/201304.mbox/%3Cf8a2ab107b47474fbc2bd194b7d8bfeb@git.apache.org%3E , i can't get anymore information about this error. Other comment on errorUrl: http://mail-archives.apache.org/mod_mbox/cordova-issues/201304.mbox/%3CJIRA.12643218.1366292135593.203365.1366659915560@arcas%3E Did any of you had this issue? Any clues on solving this? |
Mmmm, can you put on your app some code to call loginStatus again, after executing logIn ? |
@sonoman may I ask which branch were you using? 0.5.1 develop? |
@sonoman before login the response to getLoginStatus is CREATED. Some seconds After login the response is CLOSED_LOGIN_FAILED. openRequest.setCallback(new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(state, exception);
}
}); And all further calls to: private void onSessionStateChange(SessionState state, Exception exception) {
final Session session = Session.getActiveSession();
// Check if the session is open
if (state.isOpened()) {
if (loginContext != null) {
// Get user info
getUserInfo(session);
} else if (graphContext != null) {
// Make the graph call
makeGraphCall();
}
}
} results in closed state(state.isOpened() == false), what makes it never reach getUserInfo() nor makeGraphCall(). public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
Log.d(TAG, "activity result in plugin");
Session.getActiveSession().onActivityResult(cordova.getActivity(), requestCode, resultCode, intent);
} And i found out that Session.getActiveSession().onActivityResult always returns true, but Session.getActiveSession().getAccessToken(), placed right after it, returns empty string... I have also tried to change only the ConnectPlugin.java file for some older ones, but they either didn't work or got the same error... |
Just found my error!!! And i managed to do it thanks to your question about status after login @sonoman! Thank you again! try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.example.com.tvishi.fb",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
} Code above was written by Shahid Pasha (http://stackoverflow.com/users/1407064/shahid-pasha) and shows your apps Keyhashes |
Cool :) I've asked you that because I had the same problem, and I solved
|
#508 should fix the JSON error. |
Main issue resolved. |
Hi there!
My error message:
I checked my hashkey, they are all fine. Do you have any other ideas? Edit |
You need the code change proposed by sonoman at the top of this thread where he moves the line that sets the Active Session outside of an if block in the initialize() function. The change may be in the develop branch but if not you may have to make the change manually until it is (which is what I did to get things working). |
Will there be a fix for that in version |
@sebastianzillessen it's on develop https://github.com/Wizcorp/phonegap-facebook-plugin/pull/584/files will push to master 0.7.0 shortly, just testing FB Events. |
After fighting with plugin installation, i managed to load the plugin. However, it seems is not completely working....i guess there is some code not being executed...
I have this code in my first controller in my Angular application
I'm debugging the application with Android Studio, and I can tell the plugin is executing the "initialize" method...and is creating a session (although disconnected).
But then it goes to the "execute" method with action = "getLoginStatus" (everything according to the code above) but session is null, and this line on the plugin:
Of course, expodes with nullPointerException.
Any clue ?
Thanks.
The text was updated successfully, but these errors were encountered: