question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blank screen on Android

See original GitHub issue

Describe the problem

After login on the web browser nothing happens, the browser don’t redirect to the app. On iOS works great!

What was the expected behavior?

Been redirected to the app after login through the browser

Reproduction

Through a custom hook we manage the bucle to force the user to log in

import { useEffect } from 'react';

import { useAppDispatch, useAppSelector } from '../../redux/hooks';
import { handleAuth, handleAgentAuth } from '../../redux/thunks';

export const useHandleAuth0 = () => {
  const dispatch = useAppDispatch();
  const currentState = useAppSelector((state) => state.auth);

  useEffect(() => {
    const handleAuth0 = async () => {
      const response = (await dispatch(handleAuth())) as Auth0Response;

      if (response) {
        await dispatch(handleAgentAuth(response.email, response.accessToken));
      }
    };

    if (!currentState.handleAuthResponse.accessToken.length) {
      setTimeout(() => void handleAuth0(), 1000);
    }
  }, [dispatch, currentState]);
};

AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="XXXXXXXXXX">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/BootTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>
    defaultConfig {
        applicationId "xxxxxxxxxxx"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        resValue "string", "build_config_package", "xxxxxxxxxxxx"
        versionCode verCode as Integer
        versionName verName
        manifestPlaceholders = [auth0Domain: project.env.get("AUTH0_DOMAIN"), auth0Scheme: "${applicationId}"]
    }
  buildTypes {
       debug {
           applicationIdSuffix = '.dev'
           signingConfig signingConfigs.debug
       }
       dev {
           initWith release
           applicationIdSuffix = '.dev'
           matchingFallbacks = ['release']
           signingConfig signingConfigs.xxxxxxx
       }
       tst {
           initWith release
           applicationIdSuffix = '.tst'
           matchingFallbacks = ['release']
           signingConfig signingConfigs.xxxxxxx
       }
       uat {
           initWith release
           applicationIdSuffix = '.uat'
           matchingFallbacks = ['release']
           signingConfig signingConfigs.xxxxxxx
       }
       release {
           signingConfig signingConfigs.xxxxxxx
           minifyEnabled enableProguardInReleaseBuilds
           proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
       }
}

Environment

  • Version of this library used: 2.11.0
  • Which framework are you using, if applicable: RN 0.66.4
  • Other modules/plugins/libraries that might be involved: React-Native-Config 1.4.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:25 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
pupimarticommented, Jan 24, 2022

@poovamraj https://github.com/auth0/react-native-auth0/issues/83 this is exactly same issue. I was able to fix it by changing this

public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Callback cb = A0Auth0Module.this.callback;

            if (cb == null) {
                return;
            }

            boolean hasResult = resultCode == RESULT_OK &&
                    requestCode == AuthenticationActivity.AUTHENTICATION_REQUEST &&
                    data.getData() != null;
            if (hasResult) {
                cb.invoke(null, data.getData().toString());
            } else {
                final WritableMap error = Arguments.createMap();
                error.putString("error", "a0.session.user_cancelled");
                error.putString("error_description", "User cancelled the Auth");
                cb.invoke(error);
            }

            A0Auth0Module.this.callback = null;
        }
    }, 500);
}
1reaction
jalmonacidOAcommented, Feb 3, 2022

@poovamraj figure out the problem, in andoird/app/build.gradle, there is several buildTypes defined (the ones showed when this issue was open). The applicationIdSuffix is the problem, in the Allowed callbacks urls configuration the aplicationID is with and without the suffix, if i remove the applicationIdSuffix from the debug buildType, works perfect. So my problem is that, with the aplicationIdSuffix and a proper allowed callback, after login the app goes to a blank screen

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Proven Ways to Fix Android Black Screen of Death - iMobie
5 Ways to Fix Black Screen on Android Phone · Hold down the “Volume Down” key and the “Power” button simultaneously for 7...
Read more >
How to Fix Black Screen on Android Phone (2022 Update)
Way 1. Force Restart Your Android · Press and hold down the Power, Home and Volume Up/Down keys. · Press and hold down...
Read more >
How do I fix my android black screen? - Player Assist
Factory reset to fix black screen issues ; Power off the device. Power off your device and make sure its completely turned off....
Read more >
How to Fix Black Screen on Android Phone[4 Easy Methods]
3.3 How to Fix a Black Screen on a Phone via Factory Reset · 1. Power off your Android device, then press and...
Read more >
5 Simple Ways to Fix Android Phone Screen is Black - MobiKin
Method 1: You can hard reboot your Android device by holding down the "Home" and "Power" buttons simultaneously for 10 seconds, then releasing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found