Skip to content

Commit 34651c0

Browse files
authored
chore: require app_links ^6.2.0 (#1241)
1 parent 1c13bca commit 34651c0

File tree

4 files changed

+17
-58
lines changed

4 files changed

+17
-58
lines changed

.github/workflows/supabase_flutter.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ jobs:
7575
- name: Run unit tests
7676
run: flutter test --concurrency=1
7777

78-
- name: Run tests with downgraded app_links
79-
run: |
80-
flutter pub downgrade app_links
81-
flutter test --concurrency=1
82-
8378
- name: Build and test web (JS)
8479
if: ${{ matrix.os == 'ubuntu-latest' && matrix.flutter-version == '3.x'}}
8580
run: |

packages/supabase_flutter/lib/src/supabase_auth.dart

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,34 +191,22 @@ class SupabaseAuth with WidgetsBindingObserver {
191191
if (_initialDeeplinkIsHandled) return;
192192
_initialDeeplinkIsHandled = true;
193193

194-
try {
195-
Uri? uri;
194+
// Only web needs to handle initial uri. On mobile, the initial uri is
195+
// included in the uriLinkStream.
196+
if (kIsWeb) {
196197
try {
197-
// before app_links 6.0.0
198-
uri = await (_appLinks as dynamic).getInitialAppLink();
199-
} on NoSuchMethodError catch (_) {
200-
// The AppLinks package contains the initial link in the uriLinkStream
201-
// starting from version 6.0.0. Before this version, getting the
202-
// initial link was done with getInitialAppLink. Being in this catch
203-
// handler means we are in at least version 6.0.0, meaning we do not
204-
// need to handle the initial link manually.
205-
//
206-
// app_links claims that the initial link will be included in the
207-
// `uriLinkStream`, but that is not the case for web
208-
if (kIsWeb) {
209-
uri = await (_appLinks as dynamic).getInitialLink();
198+
final Uri? uri = await _appLinks.getInitialLink();
199+
if (uri != null) {
200+
await _handleDeeplink(uri);
210201
}
202+
} on PlatformException catch (err, stackTrace) {
203+
_onErrorReceivingDeeplink(err.message ?? err, stackTrace);
204+
// Platform messages may fail but we ignore the exception
205+
} on FormatException catch (err, stackTrace) {
206+
_onErrorReceivingDeeplink(err.message, stackTrace);
207+
} catch (err, stackTrace) {
208+
_onErrorReceivingDeeplink(err, stackTrace);
211209
}
212-
if (uri != null) {
213-
await _handleDeeplink(uri);
214-
}
215-
} on PlatformException catch (err, stackTrace) {
216-
_onErrorReceivingDeeplink(err.message ?? err, stackTrace);
217-
// Platform messages may fail but we ignore the exception
218-
} on FormatException catch (err, stackTrace) {
219-
_onErrorReceivingDeeplink(err.message, stackTrace);
220-
} catch (err, stackTrace) {
221-
_onErrorReceivingDeeplink(err, stackTrace);
222210
}
223211
}
224212

packages/supabase_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010
flutter: '>=3.19.0'
1111

1212
dependencies:
13-
app_links: '>=3.5.0 <7.0.0'
13+
app_links: ^6.2.0
1414
async: ^2.11.0
1515
crypto: ^3.0.2
1616
flutter:

packages/supabase_flutter/test/deep_link_test.dart

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@TestOn('!browser')
22

3-
import 'package:app_links/app_links.dart';
43
import 'package:flutter_test/flutter_test.dart';
54
import 'package:supabase_flutter/supabase_flutter.dart';
65

@@ -12,34 +11,13 @@ void main() {
1211

1312
group('Deep Link with PKCE code', () {
1413
late final PkceHttpClient pkceHttpClient;
15-
late final bool mockEventChannel;
16-
17-
/// Check if the current version of AppLinks uses an explicit call to get
18-
/// the initial link. This is only the case before version 6.0.0, where we
19-
/// can find the getInitialAppLink function.
20-
///
21-
/// CI pipeline is set so that it tests both app_links newer and older than v6.0.0
22-
bool appLinksExposesInitialLinkInStream() {
23-
try {
24-
// before app_links 6.0.0
25-
(AppLinks() as dynamic).getInitialAppLink;
26-
return false;
27-
} on NoSuchMethodError catch (_) {
28-
return true;
29-
}
30-
}
3114

3215
setUp(() async {
3316
pkceHttpClient = PkceHttpClient();
3417

35-
// Add initial deep link with a `code` parameter, use method channel if
36-
// we are in a version of AppLinks that use the explcit method for
37-
// getting the initial link. Otherwise we want to mock the event channel
38-
// and put the initial link there.
39-
mockEventChannel = appLinksExposesInitialLinkInStream();
4018
mockAppLink(
41-
mockMethodChannel: !mockEventChannel,
42-
mockEventChannel: mockEventChannel,
19+
mockMethodChannel: false,
20+
mockEventChannel: true,
4321
initialLink: 'com.supabase://callback/?code=my-code-verifier',
4422
);
4523
await Supabase.initialize(
@@ -62,9 +40,7 @@ void main() {
6240
() async {
6341
// Wait for the initial app link to be handled, as this is an async
6442
// process when mocking the event channel.
65-
if (mockEventChannel) {
66-
await Future.delayed(const Duration(milliseconds: 500));
67-
}
43+
await Future.delayed(const Duration(milliseconds: 500));
6844
expect(pkceHttpClient.requestCount, 1);
6945
expect(pkceHttpClient.lastRequestBody['auth_code'], 'my-code-verifier');
7046
});

0 commit comments

Comments
 (0)