Flutter 应用程序在使用 Branch.io 深层链接从冷状态打开时崩溃

问题描述 投票:0回答:1

我最近为在 iOS 上运行的 flutter 应用程序实现了与 Branch.io 的深度链接。当应用程序在后台运行时,它会按预期工作。单击 Branch.io 链接后,它将在我的 Flutter 应用程序中打开。但是,当应用程序完全关闭并处于冷状态时,点击链接将开始重定向到应用程序,但应用程序会立即崩溃。

这是我用于创建和打开深层链接的代码:

static Future<void> listen(BuildContext context) async {
    await FlutterBranchSdk.init();
    StreamSubscription<Map>? streamSubscription;

    streamSubscription = FlutterBranchSdk.listSession().listen((data) async {
      if (data.containsKey("groupId") && context.mounted) {
        AppNavigationV2.to(
            AppPages.groupProfileScreen, {"data": data["groupId"]});
      }
    }, onError: (error) {
      PlatformException platformException = error as PlatformException;
      print(
          'InitSession error: ${platformException.code} - ${platformException.message}');
    });
  }

  // Following this guide: 
  // https://seayeshaiftikhar.medium.com/branch-io-for-deep-linking-in-flutter-2327530f1639
  static Future<void> createLink(String groupId) async {
    BranchUniversalObject branchUniversalObject = BranchUniversalObject(
        canonicalIdentifier: 'flutter/branch',
        contentMetadata: BranchContentMetaData()
          ..addCustomMetadata('groupId', groupId),);
    FlutterBranchSdk.registerView(buo: branchUniversalObject);
    BranchLinkProperties linkProperties =
        BranchLinkProperties(feature: 'sharing');
    linkProperties.addControlParam('\$uri_redirect_mode',
        '1'); // this will redirect the link to application

    BranchResponse response = await FlutterBranchSdk.getShortUrl(
        buo: branchUniversalObject, linkProperties: linkProperties);
    Share.share(response.result);
  }

我确保运行

FlutterBranchSdk.validateSDKIntegration();
并且所有检查都已通过 - 我的
Info.plist
文件配置似乎是正确的。

Anything look amiss?

我能够使用 Mac 的控制台应用程序观看设备的输出,当应用程序崩溃时,我会看到一些如下错误消息:

[(FBSceneManager):sceneID:com.myapp.myapp-default] Update failed: <NSError: 0x3038b52f0; domain: FBSceneErrorDomain; code: 1 ("operation-failed"); "Scene update failed."> {
    NSUnderlyingError = <NSError: 0x3026896b0; domain: BSServiceConnectionErrorDomain; code: 3 ("OperationFailed"); "XPC error received on message reply handler">;
}
Process state is unknown AppStateTracker, pid 3533, uuid xxxxxxx-xxxxxxx display identifier com.myapp.myapp foreground 1
COSMCtrl _foregroundAppActivity incoming bundle com.myapp.myapp has nil supplied UUID, finds existing xxxxxxxxx-xxxx-xxx-xxx-xxxxxxxx

我也尝试了以下this解决方案,但没有成功。

在运行 iOS 18.0 的 iPhone 12 mini 上运行。有什么想法吗?

ios flutter deep-linking branch.io
1个回答
0
投票

Branchster 这里,这种问题仅在 BranchSDK 集成出现问题时才会发生。我建议您使用 Branch Dashboard 交叉检查您的捆绑包标识符、Apple 应用程序前缀、关联域和 info.plist。另外,请使用最新版本的 Flutter Branch SDK,因为新版本中已经完成了基础级别的更改。希望这能解决这个问题。如果问题仍然存在,请在此处的 github 上提出问题 - https://github.com/RodrigoSMarques/flutter_branch_sdk/issues 或在此处联系 - [电子邮件受保护]

© www.soinside.com 2019 - 2024. All rights reserved.