Skip to content

Commit 740d316

Browse files
committed
fix: app not moved to foreground after interacting with recaptcha
1 parent 5f36c2c commit 740d316

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/firebase_dart_flutter/android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
android:excludeFromRecents="true"
2929
android:exported="true"
3030
android:launchMode="singleTask"
31+
android:taskAffinity=""
3132
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
3233
<intent-filter>
3334
<action android:name="android.intent.action.VIEW" />

packages/firebase_dart_flutter/android/src/main/java/be/appsup/firebase_dart_flutter/FirebaseDartFlutterPlugin.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.net.Uri;
1111
import android.os.Bundle;
1212
import android.os.Build;
13+
import android.content.pm.PackageManager;
1314

1415

1516
import androidx.annotation.NonNull;
@@ -29,7 +30,6 @@
2930
import io.flutter.plugin.common.MethodChannel;
3031
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
3132
import io.flutter.plugin.common.MethodChannel.Result;
32-
import io.flutter.plugin.common.PluginRegistry.Registrar;
3333

3434
import com.google.android.gms.common.GoogleApiAvailability;
3535
import com.google.android.gms.common.ConnectionResult;
@@ -55,6 +55,8 @@ public class FirebaseDartFlutterPlugin implements FlutterPlugin, MethodCallHandl
5555

5656
private FlutterPluginBinding binding;
5757

58+
private Context applicationContext;
59+
5860
static final String ACTION_AUTH_RECEIVED = "be.appsup.firebase_dart_flutter.ACTION_AUTH_RECEIVED";
5961
static final String ACTION_RECAPTCHA_RECEIVED = "be.appsup.firebase_dart_flutter.ACTION_RECAPTCHA_RECEIVED";
6062

@@ -63,8 +65,17 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
6365
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "firebase_dart_flutter");
6466
channel.setMethodCallHandler(this);
6567
binding = flutterPluginBinding;
68+
applicationContext = binding.getApplicationContext();
69+
}
6670

71+
private void bringAppToFront() {
72+
Intent intent = applicationContext.getPackageManager()
73+
.getLaunchIntentForPackage(applicationContext.getPackageName());
6774

75+
if (intent != null) {
76+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
77+
applicationContext.startActivity(intent);
78+
}
6879
}
6980

7081
@Override
@@ -103,6 +114,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
103114
public void onReceive(Context context, Intent intent) {
104115
result.success(bundleToMap(intent.getExtras()));
105116
binding.getApplicationContext().unregisterReceiver(this);
117+
bringAppToFront();
106118
}
107119
};
108120
IntentFilter filter = new IntentFilter(ACTION_AUTH_RECEIVED);
@@ -114,6 +126,7 @@ public void onReceive(Context context, Intent intent) {
114126
public void onReceive(Context context, Intent intent) {
115127
result.success(bundleToMap(intent.getExtras()));
116128
binding.getApplicationContext().unregisterReceiver(this);
129+
bringAppToFront();
117130
}
118131
};
119132
filter = new IntentFilter(ACTION_RECAPTCHA_RECEIVED);

0 commit comments

Comments
 (0)