【问题标题】:application:openURL:options: not called after deeplink应用程序:openURL:选项:深度链接后未调用
【发布时间】:2018-05-02 13:49:46
【问题描述】:

简单的场景。我有一个带有 URL 方案设置的应用程序。 例如

infoplist 包含一个数组 URL 类型

该数组包含一个带有 2 个键的字典:URL 标识符(字符串)和 URL 方案(数组)

通过将标识符设置为 $(PRODUCT_BUNDLE_IDENTIFIER),标识符等于包 ID。

在这种情况下,URL 方案仅包含 1 个值“deeplink-test”。在我的 AppDelegate 中,我实现了 application:openURL:options: 方法,该方法返回 true。

现在,当我进入 Safari(在模拟器或设备上)并输入“deeplink-test://”时,Safari 会询问我是否要打开该应用程序。我选择是,但未调用深层链接。 didFinishLaunchingWithOptions 也返回 true。知道为什么不调用 openURL 委托方法吗?这曾经在一段时间前有效,但最近我注意到我们的深层链接不再被正确处理。所以应用会打开,但不会调用委托方法。

我创建了一个新项目,它的实现与它的工作原理相同。是否有我正在使用的 Pod 导致了问题?

豆荚:

pod 'Apollo' pod 'ReactiveObjC' pod 'Underscore.m' pod 'Masonry' pod 'Locksmith' pod 'INTULocationManager' pod 'GoogleAnalytics' pod 'GoogleTagManager' pod 'GoogleAppIndexing' pod 'GoogleSignIn' pod 'Firebase/Core' pod 'Firebase/Auth' pod 'Firebase/Messaging' pod 'HockeySDK' pod 'Adjust' pod 'UIDevice-Hardware' pod 'Accengage-iOS-SDK' pod 'MultiDelegate' pod 'SwipeView' pod 'DZNEmptyDataSet' pod 'FBSDKLoginKit' pod 'PINCache' pod 'FCFileManager' pod 'SnapKit' pod 'GoogleMaps' pod 'GooglePlaces' pod 'RSKGrowingTextView' pod 'FlexiblePageControl' pod 'SwiftyBeaver' pod 'Crashlytics' pod 'Fabric' pod 'React', :path => '../../node_modules/react-native', :subspecs => [ 'Core', 'RCTText', 'RCTNetwork', 'RCTWebSocket', 'RCTLinkingIOS', 'RCTImage', 'RCTAnimation', 'RCTActionSheet' ] pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga' pod 'CodePush', :path => '../../node_modules/react-native-code-push' pod 'RNDeviceInfo', :path => '../../node_modules/react-native-device-info' pod 'react-native-cookies', :path => '../../node_modules/react-native-cookies' pod 'react-native-navigation', :path => '../../node_modules/react-native-navigation' pod 'react-native-video', :path => '../../node_modules/react-native-video'

编辑 - 添加 plist 源代码:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>xx.xxx.xxx</string> <key>CFBundleURLSchemes</key> <array> <string>deeplink-test-again</string> </array> </dict> </array> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleDisplayName</key> <string>${PRODUCT_NAME} ${BUNDLE_DISPLAY_NAME_SUFFIX}</string> <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleIcons</key> <dict/> <key>CFBundleIcons~ipad</key> <dict/> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>${PRODUCT_NAME}</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>11.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>105</string> <key>Fabric</key> <dict> <key>APIKey</key> <string>xx.xxx.xxx</string> <key>Kits</key> <array> <dict> <key>KitInfo</key> <dict/> <key>KitName</key> <string>Crashlytics</string> </dict> </array> </dict> <key>FacebookAppID</key> <string>xx.xxx.xxx</string> <key>FacebookDisplayName</key> <string>xx.xxx.xxx</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>Icon files (iOS 6)</key> <dict> <key>CFBundlePrimaryIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string>icon.png</string> <string>icon@2x.png</string> </array> <key>UIPrerenderedIcon</key> <true/> </dict> </dict> <key>LSApplicationQueriesSchemes</key> <array> <string>comgooglemaps</string> <string>bma4sreceiver</string> <string>xx.xxx.xxx</string> <string>fbapi</string> <string>fb-messenger-share-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array> <key>LSRequiresIPhoneOS</key> <true/> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>xx.xxx.xxx</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>facebook.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>fbcdn.net</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict> <key>NSCalendarsUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSCameraUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSLocationAlwaysUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSLocationWhenInUseUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSPhotoLibraryAddUsageDescription</key> <string>xx.xxx.xxx</string> <key>NSPhotoLibraryUsageDescription</key> <string>xx.xxx.xxx</string> <key>UIBackgroundModes</key> <array> <string>remote-notification</string> </array> <key>UILaunchStoryboardName</key> <string>xx.xxx.xxx</string> <key>UIPrerenderedIcon</key> <true/> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UIRequiresFullScreen</key> <true/> <key>UIStatusBarHidden</key> <false/> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UIViewControllerBasedStatusBarAppearance</key> <true/> </dict> </plist>

【问题讨论】:

  • 相比 pod 列表,您的 info plist 可能更有用。
  • 另外,您可以尝试创建一个注册自定义 URL 处理程序的最小测试应用程序,看看是否适合您。这将排除任何 pod 冲突或设备问题。
  • @picciano 是有道理的。更新了问题并将 plist 信息添加为源代码。不过,不确定您的第二条评论是什么意思。用 safari 测试深度链接还不够吗?它似乎打开了应用程序,所以我猜深层链接配置正确。它只是不调用 openURL 委托方法。
  • 听起来您当前的应用程序(基于使用的 pod 数量)可能很大而且很复杂。减少深度链接到小型测试应用程序的问题可能会帮助您找出您可能做错了什么,同时消除可能干扰的无关问题。请参阅stackoverflow.com/help/mcve,以更好地了解如何缩小问题范围以提高效率。
  • 对。我已经在做一个新项目来重现那里的问题。到目前为止我做不到。只是想确保我在设置中没有做错任何事情,或者希望找到遇到同样问题的人。

标签: ios xcode delegates deep-linking deeplink


【解决方案1】:

问题出在我用于推送通知的 Pod (https://docs.accengage.com/display/IOS/SDK+Setup) 上。他们在设置过程中做了一些奇怪的事情,并自动拦截应该将其转发给应用程序的应用程序委托方法。

但它不能正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多