Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions packages/_shared/ios/Sources/FluwxPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ - (BOOL)application:(UIApplication *)application

// Available on iOS 9.0 and later
// See https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application?language=objc
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *, id> *)options {
- (BOOL)handleOrCacheOpenURL:(NSURL *)url {
// ↓ previous solution -- according to document, this may fail if the WXApi hasn't registered yet.
// return [WXApi handleOpenURL:url delegate:self];

Expand All @@ -442,6 +440,31 @@ - (BOOL)application:(UIApplication *)app
}
}

- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *, id> *)options {
return [self handleOrCacheOpenURL:url];
}

// Fix wx-open-launch-app cold starts when using FlutterSceneDelegate. Custom URL schemes are
// delivered through UIScene connection options on cold start and openURLContexts while running.
- (BOOL)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0)) {
BOOL handled = NO;
for (UIOpenURLContext *context in URLContexts) {
handled = [self handleOrCacheOpenURL:context.URL] || handled;
}
return handled;
}

- (BOOL)scene:(UIScene *)scene
willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)) {
if (connectionOptions == nil || connectionOptions.URLContexts.count == 0) {
return NO;
}
return [self scene:scene openURLContexts:connectionOptions.URLContexts];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *_Nonnull))restorationHandler{
// TODO: (if need) cache userActivity and handle it once WXApi is registered
return [WXApi handleOpenUniversalLink:userActivity delegate:self];
Expand Down Expand Up @@ -1592,4 +1615,4 @@ - (NSString*)fetchWeChatAppId {
return nil;
}

@end
@end
Loading