Skip to content
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

Fix Login Callback #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.facebook.unity;

import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;

import android.app.Activity;
import android.content.Intent;
Expand All @@ -30,6 +31,8 @@ public class FBUnityLoginActivity extends BaseActivity {
public static final String LOGIN_PARAMS = "login_params";
public static final String LOGIN_TYPE = "login_type";

private boolean didReceiveActivityResult = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -62,4 +65,20 @@ public enum LoginType {
TV_PUBLISH
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
didReceiveActivityResult = true;
}

@Override
public void onDestroy() {
super.onDestroy();
if(!didReceiveActivityResult)
{
didReceiveActivityResult = true;
int loginRequestCode = FacebookSdk.getCallbackRequestCodeOffset();
mCallbackManager.onActivityResult(loginRequestCode, RESULT_CANCELED, null);
}
}
}