llfbandit / app_links

Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
https://pub.dev/packages/app_links
Apache License 2.0
176 stars 68 forks source link

ios application open should not always return true #17

Closed zmtzawqlp closed 2 years ago

zmtzawqlp commented 2 years ago

thanks for this amazing plugin.

i meet one problem that i use another plugin(wechat_kit) that it also need to handle application open.

i see that code in AppLinks is always return true, it will stop wechat_kit to share.

should we provide a method to get which scheme should we handle? or handleLink has a return value?

  public func application(
    _ application: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

    handleLink(url: url)
    return true
  }
llfbandit commented 2 years ago

Thanks for the report!

Adding patterns to know how to react would be very complex, error prone and won't add much control. I agree, it should be somehow that way, but re-adding patterns inside dart code which are already defined in external config files would be a pain... I'm without fine grained solution for now.

I guess we can always return false to avoid those blocking scenarios. It has already been done with universal links. For now, I haven't get any issues for myself and others since the change.

zmtzawqlp commented 2 years ago

thanks your quickly reply, do you have a plan to a release recently?

llfbandit commented 2 years ago

Change applied in version 3.0.2

zmtzawqlp commented 2 years ago

maybe we still need to find out a way to know whether we had handled current url.

Associated Domains is set, and lanuch app with UniversalLinks, it will still go into weibo_kit, then got error

https://github.com/RxReader/weibo_kit/issues/46

droplet-js commented 2 years ago

@zmtzawqlp 可以通过在 pubspec.yaml 里配置 domain 的方式来使用 app_link,类似

# https://github.com/RxReader/wechat_kit/blob/master/ios/wechat_kit.podspec
calling_dir = File.dirname(__FILE__)
flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks')))
# cfg = YAML.load_file(File.join(File.expand_path('../../../../..', File.dirname(__FILE__)), 'pubspec.yaml'))
cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml'))
if cfg['wechat_kit']
    if cfg['wechat_kit']['ios'] == 'no_pay'
        wechat_kit_subspec = 'no_pay'
    else
        wechat_kit_subspec = 'pay'
    end
end
# https://github.com/firebase/flutterfire/blob/master/packages/firebase_crashlytics/firebase_crashlytics/ios/firebase_crashlytics.podspec
s.pod_target_xcconfig = {
    'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\@\\\"#{library_version}\\\" LIBRARY_NAME=\\@\\\"flutter-fire-cls\\\"",
    'DEFINES_MODULE' => 'YES'
  }
zmtzawqlp commented 2 years ago

@zmtzawqlp 可以通过在 pubspec.yaml 里配置 domain 的方式来使用 app_link,类似

# https://github.com/RxReader/wechat_kit/blob/master/ios/wechat_kit.podspec
calling_dir = File.dirname(__FILE__)
flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks')))
# cfg = YAML.load_file(File.join(File.expand_path('../../../../..', File.dirname(__FILE__)), 'pubspec.yaml'))
cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml'))
if cfg['wechat_kit']
    if cfg['wechat_kit']['ios'] == 'no_pay'
        wechat_kit_subspec = 'no_pay'
    else
        wechat_kit_subspec = 'pay'
    end
end
# https://github.com/firebase/flutterfire/blob/master/packages/firebase_crashlytics/firebase_crashlytics/ios/firebase_crashlytics.podspec
s.pod_target_xcconfig = {
    'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\@\\\"#{library_version}\\\" LIBRARY_NAME=\\@\\\"flutter-fire-cls\\\"",
    'DEFINES_MODULE' => 'YES'
  }

no_pay 和 pay 的区别。是其中一个会crash?