Nuera authentication screen isn't opened when calling neuraApiClient.authenticate(...)

85 Views Asked by At

I'm working with Neura sdk in order to detect special events of my users( arriving/leaving home) I'm trying to initiate their authentication, as described below (fetchPermissions() and initNeuraConnection() are the same as in the documentations, and mAuthenticationRequest is initiated on fetchPermissions())

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getMainActivity().initNeuraConnection();
    fetchPermissions();
    getMainActivity().getClient().authenticate(NEURA_AUTHENTICATION_REQUEST_CODE, mAuthenticateRequest);
}

My issue is that once i call authenticate - nothing happens and the neura login screen isn't opened

1

There are 1 best solutions below

1
On BEST ANSWER

There are few things you can check :

Have you declared initNueraConnection() and fetchPermissions() as described in the Neura dev site ?

If so, I suspect you're sending authenticate(...) a nullable mAuthenticateRequest instance. Since fetchPermissions() is asynchronous(its a network call), you're calling authenticate(...) before the results are fetched from fetchPermissions(), so, mAuthenticateRequest is null, since it's not initiated yet. You should call authenticate(...) only after you recieve the data on fetchPermissions().

For example, you can do this :

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getMainActivity().initNeuraConnection();
    fetchPermissions();
}
private void fetchPermissions() {
    loadProgress(true);
    getMainActivity().getClient().getAppPermissions(new GetPermissionsRequestCallbacks() {
        @Override
        public void onSuccess(final List<Permission> permissions) throws RemoteException {
            if (getActivity() == null)
                return;
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    loadProgress(false);
                    mPermissions = new ArrayList<>(permissions);
                    mAuthenticateRequest = new AuthenticationRequest();
                    mAuthenticateRequest.setAppId(getMainActivity().getClient().getAppUid());
                    mAuthenticateRequest.setAppSecret(getMainActivity().getClient().getAppSecret());
                    mAuthenticateRequest.setPermissions(mPermissions);

                    getMainActivity().getClient().authenticate(NEURA_AUTHENTICATION_REQUEST_CODE, mAuthenticateRequest);
                }
            });
        }

        @Override
        public void onFailure(Bundle resultData, int errorCode) throws RemoteException {
            loadProgress(false);
            mRequestPermissions.setEnabled(true);
        }

        @Override
        public IBinder asBinder() {
            return null;
        }
    });
}

Fyi, you can check your logcat for this error : authenticationRequest is nullable, couldn't create authenticate request.