在 iOS 上使用 Branch.io 的 applicationDidBecomeActive 崩溃

Crash on applicationDidBecomeActive with Branch.io on iOS

TL;DR
错误是 url 中的 space 未被编码。将由他们这边的 Branch Guys 修复


我集成了 iOS SDK 并按照指南中的说明完成了通用链接的所有设置。我已正确配置所有内容(或看起来如此),打开 link 将我带到应用程序。 然而,这个问题似乎与深度linking 功能无关。

步骤:

1.- 打开应用程序
2.- 返回主屏幕(不要关闭应用程序)
3.- 再次打开应用程序
4.- 崩溃

指定的 URL 有一个不支持的方案。仅支持 HTTP 和 HTTPS URL

线路崩溃是(BNCStrongMatchHelper.m:114):
UIViewController * safController = [[SFSafariViewControllerClass alloc] initWithURL:[NSURL URLWithString:urlString]];

但是此时urlString是一个httpslink.

更多信息:

    Fatal Exception: NSInvalidArgumentException
    0 CoreFoundation 0x1819bae38 __exceptionPreprocess
    1 libobjc.A.dylib 0x18101ff80 objc_exception_throw
    2 CoreFoundation 0x1819bad80 -[NSException initWithCoder:]
    3 SafariServices 0x18dd9e3fc -[SFSafariViewController initWithURL:entersReaderIfAvailable:]
    4 [myapp] 0x1002acc00 -[BNCStrongMatchHelper presentSafariVCWithBranchKey:] (BNCStrongMatchHelper.m:114)
    5 [myapp] 0x1002ac590 -[BNCStrongMatchHelper createStrongMatchWithBranchKey:] (BNCStrongMatchHelper.m:66)
    6 [myapp] 0x1002bdef0 -[Branch registerInstallOrOpen:] (Branch.m:1369)
    7 [myapp] 0x1002bdd74 -[Branch initializeSession] (Branch.m:1354)
    8 [myapp] 0x1002bd914 -[Branch initUserSessionAndCallCallback:] (Branch.m:1328)
    9 [myapp] 0x1002bc104 -[Branch applicationDidBecomeActive] (Branch.m:1203)
    10 CoreFoundation 0x18195ceac __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
    11 CoreFoundation 0x18195c6cc _CFXRegistrationPost
    12 CoreFoundation 0x18195c44c ___CFXNotificationPost_block_invoke
    13 CoreFoundation 0x1819c5494 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
    14 CoreFoundation 0x18189a788 _CFXNotificationPost
    15 Foundation 0x1822a289c -[NSNotificationCenter postNotificationName:object:userInfo:]
    16 UIKit 0x186b8e014 -[UIApplication _stopDeactivatingForReason:]
    17 UIKit 0x186dacdc4 __62-[UIApplication _sceneSettingsPostLifecycleEventDiffInspector]_block_invoke1180
    18 FrontBoardServices 0x18334c7b4 __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke27
    19 Foundation 0x1823517e8 __NSIndexSetEnumerate
    20 BaseBoard 0x1832d4728 -[BSSettingsDiff inspectChangesWithBlock:]
    21 FrontBoardServices 0x183347d94 -[FBSSettingsDiff inspectOtherChangesWithBlock:]
    22 FrontBoardServices 0x18334c58c -[FBSSettingsDiffInspector inspectDiff:withContext:]
    23 UIKit 0x186dad648 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
    24 UIKit 0x186dad2a4 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]
    25 FrontBoardServices 0x18335b7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
    26 FrontBoardServices 0x18335b618 -[FBSSerialQueue _performNext]
    27 FrontBoardServices 0x18335b9c8 -[FBSSerialQueue _performNextFromRunLoopSource]
    28 CoreFoundation 0x181971124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
    29 CoreFoundation 0x181970bb8 __CFRunLoopDoSources0
    30 CoreFoundation 0x18196e8b8 __CFRunLoopRun
    31 CoreFoundation 0x181898d10 CFRunLoopRunSpecific
    32 GraphicsServices 0x183180088 GSEventRunModal
    33 UIKit 0x186b6df70 UIApplicationMain
    34 [myapp] 0x1001b6984 main (main.m:16)
    35 libdispatch.dylib 0x1814368b8 (Missing)

尝试将此添加到您的 Info.plist 文件中:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

来自 Branch.io 的 Alex 进行了更新:经过一些调试,我们确定这是由于 urlString 中的 space(从应用程序版本号通过)。删除此 space 解决了崩溃问题。

Branch 端的一个更永久的解决方案也在开发中。