Skip to content

Commit ec2c3d1

Browse files
committed
aboutyou#162: Ensure Chrome Custom Tab does not disappear when switching away and back from the app during Sign in with Apple
1 parent 9b7eab6 commit ec2c3d1

File tree

10 files changed

+108
-19
lines changed

10 files changed

+108
-19
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ ios/vendor
9191
android/vendor
9292

9393
**/coverage/lcov.info
94+
95+
.fvm/

packages.code-workspace

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "packages/pending_operations"
5+
},
6+
{
7+
"path": "packages/sign_in_with_apple/sign_in_with_apple_platform_interface"
8+
},
9+
{
10+
"path": "packages/sign_in_with_apple/sign_in_with_apple"
11+
},
12+
{
13+
"path": "packages/sign_in_with_apple/sign_in_with_apple_web"
14+
},
15+
{
16+
"path": "packages/state_queue"
17+
},
18+
{
19+
"path": "packages/state_queue_test"
20+
},
21+
{
22+
"path": "packages/with_bloc"
23+
},
24+
{
25+
"path": ".github"
26+
}
27+
],
28+
"settings": {
29+
"dart.lineLength": 80,
30+
"search.exclude": {
31+
"**/.fvm": true,
32+
},
33+
"files.exclude": {
34+
"**/.fvm": true
35+
}
36+
}
37+
}

packages/sign_in_with_apple/sign_in_with_apple/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 4.3.0
2+
3+
- Android: Fixes an issue where the Chrome Custom Tab would disappear when the user "left" the app (e.g. using the app switcher) ([#162](https://github.com/aboutyou/dart_packages/issues/162))
4+
- Beware that your app's `launchMode` affects the specific behavior of the Chrome Custom Tab. For more information see the README.
5+
16
## 4.2.0
27

38
- Remove `jcenter` repository for the Android package

packages/sign_in_with_apple/sign_in_with_apple/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ You can find out if you are already using the new embedding by looking into your
138138

139139
In case you are not yet using Android V2 Embedding, please first upgrade your app using the following guide: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
140140

141+
#### `launchMode`
142+
143+
To ensure that deep links from the login web page (shown in a Chrome Custom Tab) back to the app still work, your app must use `launchMode` `singleTask` or `singleTop`
144+
- When using `singleTask` the Chrome Custom Tab persists across app switches from within Android's app switcher, but will be dismissed when the app is launched anew from the home screen icon / app gallery
145+
- With launch mode `singleTop` the Chrome Custom Tab stays present both after using the app switcher or launching the app anew via its icon
146+
- If you change your app's `launchMode` be sure to test any other third-party integrations that might be affected by this (e.g. deep links)
147+
141148
### Web
142149

143150
For web support you need to add the follow script import to your `index.html`'s `<head>` tag:

packages/sign_in_with_apple/sign_in_with_apple/android/src/main/kotlin/com/aboutyou/dart_packages/sign_in_with_apple/SignInWithApplePlugin.kt

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public class SignInWithApplePlugin: FlutterPlugin, MethodCallHandler, ActivityAw
9191

9292
val builder = CustomTabsIntent.Builder();
9393
val customTabsIntent = builder.build();
94-
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
9594
customTabsIntent.intent.data = Uri.parse(url)
9695

9796
_activity.startActivityForResult(

packages/sign_in_with_apple/sign_in_with_apple/example/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,25 @@ flutter config --enable-macos-desktop
1313
# cd macos && bundle exec pod install && cd -
1414
flutter run -d macOS
1515
```
16+
17+
## Test Android deep links
18+
19+
### Simulate a callback from the SiwA process
20+
21+
This mimicks the `intent://` link the success redirect would use
22+
23+
```
24+
adb shell am start -a android.intent.action.VIEW \
25+
-c android.intent.category.BROWSABLE \
26+
-d "signinwithapple://callback?code=abc123" com.aboutyou.dart_packages.sign_in_with_apple.example
27+
```
28+
29+
### Simulate a deep link into the app
30+
31+
```
32+
adb shell am start -a android.intent.action.VIEW \
33+
-c android.intent.category.BROWSABLE \
34+
-d "siwa-example://siwa.example.com/foo" com.aboutyou.dart_packages.sign_in_with_apple.example
35+
```
36+
37+
This will close the Chrome Custom Tab if a SiwA login flow is active, and then show the deep link inside the app (just a `print` in the example)

packages/sign_in_with_apple/sign_in_with_apple/example/android/app/src/main/AndroidManifest.xml

+9
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@
2020
android:name="io.flutter.embedding.android.NormalTheme"
2121
android:resource="@style/NormalTheme"
2222
/>
23+
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
24+
2325
<intent-filter>
2426
<action android:name="android.intent.action.MAIN"/>
2527
<category android:name="android.intent.category.LAUNCHER"/>
2628
</intent-filter>
29+
<intent-filter>
30+
<action android:name="android.intent.action.VIEW" />
31+
<category android:name="android.intent.category.DEFAULT" />
32+
<category android:name="android.intent.category.BROWSABLE" />
33+
34+
<data android:scheme="siwa-example" android:host="siwa.example.com" />
35+
</intent-filter>
2736
</activity>
2837

2938
<!-- Set up the Sign in with Apple activity, such that it's callable from the browser-redirect -->

packages/sign_in_with_apple/sign_in_with_apple/example/lib/main.dart

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ class _MyAppState extends State<MyApp> {
2424
@override
2525
Widget build(BuildContext context) {
2626
return MaterialApp(
27+
onGenerateRoute: ((settings) {
28+
// This is also invoked for incoming deep links
29+
30+
// ignore: avoid_print
31+
print('onGenerateRoute: $settings');
32+
33+
return null;
34+
}),
2735
home: Scaffold(
2836
appBar: AppBar(
2937
title: const Text('Example app: Sign in with Apple'),

packages/sign_in_with_apple/sign_in_with_apple/example/pubspec.lock

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.8.2"
10+
version: "2.9.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,7 +21,7 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.2.0"
24+
version: "1.2.1"
2525
charcode:
2626
dependency: transitive
2727
description:
@@ -35,21 +35,21 @@ packages:
3535
name: clock
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "1.1.0"
38+
version: "1.1.1"
3939
collection:
4040
dependency: transitive
4141
description:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0"
45+
version: "1.16.0"
4646
fake_async:
4747
dependency: transitive
4848
description:
4949
name: fake_async
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.2.0"
52+
version: "1.3.1"
5353
flutter:
5454
dependency: "direct main"
5555
description: flutter
@@ -92,7 +92,7 @@ packages:
9292
name: js
9393
url: "https://pub.dartlang.org"
9494
source: hosted
95-
version: "0.6.3"
95+
version: "0.6.4"
9696
lints:
9797
dependency: transitive
9898
description:
@@ -106,28 +106,28 @@ packages:
106106
name: matcher
107107
url: "https://pub.dartlang.org"
108108
source: hosted
109-
version: "0.12.11"
109+
version: "0.12.12"
110110
material_color_utilities:
111111
dependency: transitive
112112
description:
113113
name: material_color_utilities
114114
url: "https://pub.dartlang.org"
115115
source: hosted
116-
version: "0.1.3"
116+
version: "0.1.5"
117117
meta:
118118
dependency: transitive
119119
description:
120120
name: meta
121121
url: "https://pub.dartlang.org"
122122
source: hosted
123-
version: "1.7.0"
123+
version: "1.8.0"
124124
path:
125125
dependency: transitive
126126
description:
127127
name: path
128128
url: "https://pub.dartlang.org"
129129
source: hosted
130-
version: "1.8.0"
130+
version: "1.8.2"
131131
pedantic:
132132
dependency: transitive
133133
description:
@@ -148,7 +148,7 @@ packages:
148148
path: ".."
149149
relative: true
150150
source: path
151-
version: "4.0.0"
151+
version: "4.2.0"
152152
sign_in_with_apple_platform_interface:
153153
dependency: "direct overridden"
154154
description:
@@ -174,7 +174,7 @@ packages:
174174
name: source_span
175175
url: "https://pub.dartlang.org"
176176
source: hosted
177-
version: "1.8.1"
177+
version: "1.9.0"
178178
stack_trace:
179179
dependency: transitive
180180
description:
@@ -195,21 +195,21 @@ packages:
195195
name: string_scanner
196196
url: "https://pub.dartlang.org"
197197
source: hosted
198-
version: "1.1.0"
198+
version: "1.1.1"
199199
term_glyph:
200200
dependency: transitive
201201
description:
202202
name: term_glyph
203203
url: "https://pub.dartlang.org"
204204
source: hosted
205-
version: "1.2.0"
205+
version: "1.2.1"
206206
test_api:
207207
dependency: transitive
208208
description:
209209
name: test_api
210210
url: "https://pub.dartlang.org"
211211
source: hosted
212-
version: "0.4.8"
212+
version: "0.4.12"
213213
typed_data:
214214
dependency: transitive
215215
description:
@@ -223,7 +223,7 @@ packages:
223223
name: vector_math
224224
url: "https://pub.dartlang.org"
225225
source: hosted
226-
version: "2.1.1"
226+
version: "2.1.2"
227227
sdks:
228-
dart: ">=2.14.0 <3.0.0"
228+
dart: ">=2.17.0-0 <3.0.0"
229229
flutter: ">=2.8.0"

packages/sign_in_with_apple/sign_in_with_apple/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sign_in_with_apple
22
description: Flutter bridge to initiate Sign in with Apple (on iOS, macOS, and Android). Includes support for keychain entries as well as signing in with an Apple ID.
3-
version: 4.2.0
3+
version: 4.3.0
44
homepage: https://github.com/aboutyou/dart_packages/tree/master/packages/sign_in_with_apple
55
repository: https://github.com/aboutyou/dart_packages
66

0 commit comments

Comments
 (0)