I'm trying to use the Gigya callback for onPendingRegistration
because our registration requires additional details when a user logs in with social media. The initial social registration works fine because I can verify that the user exists in the Gigya console but the registration for our specific app doesn't push through because of the pending registration status.
Currently my login function has the callbacks for onSuccess
, onError
, and onPendingRegistration
. For some reason it always goes into the onError
callback but when checking the logs, it says that the error is 206001 which is "Account Pending Registration"
Login Function
public void facebookLoginTapped(View view) {
processGigyaLogin(FACEBOOK);
}
private void processGigyaLogin(String loginProvider) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("screenSet","GIGYA-RegistrationLogin");
params.put("startScreen","gigya-complete-registration-screen");
mGigya.login(loginProvider, new HashMap<>(), new GigyaLoginCallback<MyAccount>() {
@Override
public void onSuccess(MyAccount obj) {
// Success
Log.i("GIGYA-CDC", obj.toString());
}
@Override
public void onError(GigyaError error) {
// Fail
Log.e("GIGYA-CDC", error.toString());
}
@Override
public void onPendingRegistration(@NonNull GigyaApiResponse response, @NonNull IPendingRegistrationResolver resolver) {
Log.d("GIGYA-CDC", "onPendingRegistration");
}
});
}
I found the problem. You need to make sure that the native app part is working for interruptions to work. So for the past few weeks I had to work with setting up the social logins without using the native SDKs as they were still being setup by a different team. Anyway long story short, once I started wiring up the native SDK with the app (ie using the Facebook or Google app to do the authentication), then the @Override
methods in the SDK v4 documentation starts to work.
As earlier noted by TalMihr, you shouldn't be using screen-sets
with the interruptions and work with the resolver
interfaces. I'm working on that right now and I'll update my answer once I get the actual resolver object to work.
FYI: My current setup to make this work(using Gigya SDK v 4.0.1):
//Facebook
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
//Google Sign In
implementation 'com.google.android.gms:play-services-auth:16.0.1'
Everything else is similar to the sample app in terms of code.
Edit:
It works! I haven't used the resolver
interface to work this out btw. I was told to try and make screen-sets work as we wanted to avoid creating additional UI. How it works is you'd need to provide additional parameters when you use the screen-set.
Pending Registration Code:
private void processGigyaLogin(String loginProvider) {
mGigya = Gigya.getInstance(MyAccount.class);
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("screenSet","SCREEN-SET-RegistrationLogin");
params.put("startScreen","gigya-complete-registration-screen");
mGigya.login(loginProvider, new HashMap<>(), new GigyaLoginCallback<MyAccount>() {
@Override
public void onSuccess(MyAccount obj) {
// Success
Log.i("GIGYA-CDC", "Logged in using" + obj.getSocialProviders() + " as: " + obj.getProfile().getFirstName() + " " + obj.getProfile().getLastName() + ", " + obj.getProfile().getEmail());
}
@Override
public void onConflictingAccounts(@NonNull GigyaApiResponse response, @NonNull ILinkAccountsResolver resolver) {
Log.d("GIGYA-CDC", "onConflictingAccounts");
}
@Override
public void onPendingRegistration(@NonNull GigyaApiResponse response, @NonNull IPendingRegistrationResolver resolver) {
Log.d("GIGYA-CDC", "onPendingRegistration");
params.put("regToken", response.getField("regToken", String.class));
mGigya.showScreenSet("SCREEN-SET-RegistrationLogin", false, params, new GigyaPluginCallback<MyAccount>() {
@Override
public void onLogin(@NonNull MyAccount obj) {
Log.i("GIGYA-CDC", "Logged in using" + obj.getSocialProviders() + " as: " + obj.getProfile().getFirstName() + " " + obj.getProfile().getLastName() + ", " + obj.getProfile().getEmail());
}
});
}
@Override
public void onError(GigyaError error) {
Log.e("GIGYA-CDC", error.getLocalizedMessage() + " Status Code: " + error.getStatusCode() + " Error Code: " + error.getErrorCode());
}
});
}