Skip to content

Commit a2a184e

Browse files
yusuftorclaude
andcommitted
Revert to simple solution using original shared.handleDeepLink instance method
- Keep only the original shared.handleDeepLink() instance method for simplicity - Handle initial deep links after configure() completes in the completion callback - iOS: Uses static Superwall.handleDeepLink() native method that safely queues links - Android: Uses instance method after configuration - Move _handleInitialLink() call to configure completion to ensure SDK is ready This is the cleanest approach that leverages the native iOS queuing without adding complexity or breaking changes to the Flutter API. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2abb5b7 commit a2a184e

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

example/lib/main.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class _MyAppState extends State<MyApp> {
2929
const useRevenueCat = true;
3030

3131
super.initState();
32-
_handleIncomingLinks(); // Set up deep link handling before configuration
33-
_handleInitialLink(); // Handle cold start deep links
32+
_handleIncomingLinks(); // Set up deep link handling
3433
configureSuperwall(useRevenueCat);
3534
}
3635

@@ -43,7 +42,7 @@ class _MyAppState extends State<MyApp> {
4342
void _handleIncomingLinks() {
4443
appLinks.uriLinkStream.listen((Uri uri) {
4544
debugPrint('Incoming deep link: $uri');
46-
Superwall.handleDeepLink(uri);
45+
Superwall.shared.handleDeepLink(uri);
4746
}, onError: (Object err) {
4847
print('Error receiving incoming link: $err');
4948
});
@@ -53,8 +52,8 @@ class _MyAppState extends State<MyApp> {
5352
appLinks.getInitialLink().then((Uri? initialUri) {
5453
if (initialUri != null) {
5554
debugPrint('Initial deep link (cold start): $initialUri');
56-
// Safe to call before configure() - static method bypasses shared instance
57-
Superwall.handleDeepLinkStatic(initialUri);
55+
// Handle after configure completes - iOS SDK will queue it automatically
56+
Superwall.shared.handleDeepLink(initialUri);
5857
}
5958
}).catchError((Object err) {
6059
print('Error getting initial link: $err');
@@ -97,6 +96,7 @@ class _MyAppState extends State<MyApp> {
9796
logging.info('Executing Superwall configure completion block');
9897
print('Executing Superwall configure completion block');
9998
listenForPurchases();
99+
_handleInitialLink(); // Handle cold start deep links after configure
100100
});
101101
Superwall.shared.setDelegate(delegate);
102102
// MARK: Step 3 – Configure RevenueCat and Sync Subscription Status

lib/src/public/Superwall.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,13 @@ class Superwall {
350350
await hostApi.preloadPaywallsForPlacements(placementNames.toList());
351351
}
352352

353-
// Instance method for backward compatibility
353+
// Handles deep links for paywall previews
354+
// iOS: Uses static Superwall.handleDeepLink() that safely queues links before configuration
355+
// Android: Uses instance method, works after configuration
354356
Future<bool> handleDeepLink(Uri url) async {
355357
return await hostApi.handleDeepLink(url.toString());
356358
}
357359

358-
// Static method safe to call before configure() - bypasses shared instance
359-
// iOS: Uses static Superwall.handleDeepLink() that queues links before configuration
360-
// Android: Attempts immediate processing with instance method
361-
static Future<bool> handleDeepLinkStatic(Uri url) async {
362-
return await hostApi.handleDeepLink(url.toString());
363-
}
364-
365360
// Toggles the paywall loading spinner
366361
Future<void> togglePaywallSpinner(bool isHidden) async {
367362
await hostApi.togglePaywallSpinner(isHidden);

0 commit comments

Comments
 (0)