Простой сценарий. У меня есть приложение с настройкой схем URL. например
infoplist содержит типы URL-адресов массива
Этот массив содержит словарь с двумя ключами: идентификатор URL (строка) и схемы URL (массив)
Идентификатор равен идентификатору пакета, задав для него значение $ (PRODUCT_BUNDLE_IDENTIFIER).
В этом случае схемы URL-адресов содержат только 1 значение «deeplink-test». В моем AppDelegate реализован метод application: openURL: options:, который возвращает true.
Теперь, когда я захожу в Safari (на симуляторе или устройстве) и набираю «deeplink-test: //», Safari спрашивает меня, хочу ли я открыть приложение. Я выбираю да, но диплинк не вызывается. didFinishLaunchingWithOptions также возвращает true. Есть идеи, почему не вызывается метод делегата openURL? Раньше это работало некоторое время назад, но недавно я заметил, что наши deeplink-ссылки больше не обрабатываются правильно. Итак, приложение откроется, но метод делегата не будет вызван.
Я создал новый проект с той же реализацией, в которой он работает. Может быть, я использую 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>[email protected]</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>
Кроме того, вы можете попробовать создать минимальное тестовое приложение, которое регистрирует пользовательский обработчик URL-адресов, и посмотреть, работает ли это для вас. Это исключит любые конфликты модулей или проблемы с устройством.
@picciano имеет смысл. Обновил вопрос и добавил информацию о plist в качестве исходного кода. Не уверен, что вы имеете в виду со своим вторым комментарием. Чем недостаточно тестирования deeplink с помощью сафари? Кажется, открывается приложение, поэтому я думаю, что deeplink настроен правильно. Он просто не вызывает метод делегата openURL.
Похоже, ваше текущее приложение (в зависимости от количества используемых модулей) может быть большим и сложным. Уменьшение проблемы с глубокими ссылками на небольшое тестовое приложение может помочь вам выяснить, что вы сделали неправильно, и при этом устранить несвязанные проблемы, которые могут мешать. См. stackoverflow.com/help/mcve, чтобы лучше понять, как сузить ваш вопрос, чтобы быть более эффективным.
Верно. Я уже работал над новым проектом, чтобы воспроизвести проблему там. Пока не могу. Просто хотел убедиться, что я не делаю ничего плохого в настройке или надеюсь найти кого-то, у кого была такая же проблема.
Проблема оказалась в модуле, который я использовал для push-уведомлений (https://docs.accengage.com/display/IOS/SDK+Setup). Они делают что-то странное во время настройки и автоматически перехватывают методы делегата приложения, которые должен перенаправляют его затем в приложение.
Однако это работает некорректно.
Ваш информационный лист может быть более полезным, чем список модулей.