Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS AppDelegate 中配置了 Universal link 处理器,会覆盖掉 ios/Classes/FluwxPlugin.m 中配置的 #691

Closed
kawayiLinLin opened this issue Mar 13, 2025 · 2 comments

Comments

@kawayiLinLin
Copy link

kawayiLinLin commented Mar 13, 2025

Describe the bug
Universal link 的冲突

To Reproduce

  1. 首先引入 fluwx,然后进行一些配置后,fluwx 能正常登录微信
  2. 然后在 AppDelegate 中
@main
@objc class AppDelegate: FlutterAppDelegate, FluwxDelegate {
    override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
            guard let url = userActivity.webpageURL else { return false }
            print("ios native message application3")
            print(url)
            handleIncomingUrl(url: url)
            return true
        }
        return false
    }
}

覆盖这个东西,让应用能够拿到并解析 Universal Link 的路径
3. 应用能够正常拿到路径,但是 fluwx 拿不到了,也就是这里的代码 ,导致从微信登录跳回来时,fluwx 并不能正常返回code
https://github.com/OpenFlutter/fluwx/blob/main/ios/Classes/FluwxPlugin.m#L448

Which version of Fluwx do you use?
5.3.1

Which device do you run on
iPhone se

Which Flutter do you use?
Flutter (Channel stable, 3.22.2, on macOS 14.2.1 23C71 darwin-x64, locale zh-Hans-CN)
Xcode - develop for iOS and macOS (Xcode 15.3)

可能的解决办法
~/ios/Classes/public/FluwxPlugin.h
#import <Flutter/Flutter.h>

@interface FluwxPlugin : NSObject
@EnD
在这个文件中,增加一些公开的方法,让外部能够手动调用 [WXApi handleOpenUniversalLink:userActivity delegate:self] 这一行代码

或者在 ios/Classes/FluwxPlugin.m 中添加一些监听器,让我外部代码能触发已添加的监听器,从而触发 [WXApi handleOpenUniversalLink:userActivity delegate:self]

@JarvanMo
Copy link
Member

我不是太懂iOS,可以提个PR么

@kawayiLinLin
Copy link
Author

确认了文档里有说明,需要调用 super,不是bug,不需要提pr

如果您必须覆盖这两个函数,请确保您已经调用super:

  • (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

return [super application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

  • (BOOL)application:(UIApplication *)application openURL:(NSURL )url options:(NSDictionary<NSString, id> *)options
    {

return [super application:application openURL:url options:options];
}

补充 swift 的实现

override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        let superResult = super.application(application, continue: userActivity, restorationHandler: restorationHandler)
        // custom code
        return superResult
}

此issue关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants