Flutter App 在收到 Airship 的推送通知后在 iOS 上崩溃

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

我们最近仅在 iOS 上遇到应用程序崩溃的情况(在 Android 上运行正常),在收到和/或点击来自 Airship with Flutter 的推送通知后。

我们收到的错误如下所示:

-[__NSCFType userNotificationCenter:willPresentNotification:withCompletionHandler:]: unrecognized selector sent to instance 0x283cad3b0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType userNotificationCenter:willPresentNotification:withCompletionHandler:]: unrecognized selector sent to instance 0x283cad3b0'
*** First throw call stack:
(0x198f30cb4 0x191fd83d0 0x1990a5ab8 0x198f470e8 0x198fad900 0x102d66fc0 0x10456016c 0x102d66fc0 0x10456016c 0x103445300 0x1034437e4 0x19b39116c 0x19b1a04bc 0x19b1a0260 0x19b1a00a0 0x1aefa1a04 0x1aefa1840 0x1aefa505c 0x1aefa4f78 0x1a03f6eac 0x1a03fa91c 0x1aefaf188 0x1aefaed24 0x1aefb15d0 0x198ffa128 0x1990067b4 0x198f8b5e8 0x198fa10d4 0x198fa63ec 0x1d446b35c 0x19b3336e8 0x19b33334c 0x102ca5808 0x1b84a6dec)
libc++abi: terminating due to uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001d7e9a558 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1d7e9a558 <+8>:  b.lo   0x1d7e9a578               ; <+40>
    0x1d7e9a55c <+12>: pacibsp 
    0x1d7e9a560 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1d7e9a564 <+20>: mov    x29, sp

pubspec.yaml
中的依赖关系:

dependencies:
  airship_flutter: ^6.3.0
  firebase_analytics: ^10.4.1
  firebase_core: ^2.13.0
  firebase_crashlytics: ^3.3.1
  firebase_messaging: ^14.6.1
  flutter:
    sdk: flutter
  flutter_bloc: ^8.1.2
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0
ios flutter firebase push-notification urbanairship.com
2个回答
0
投票

问题出在 firebase_messaging 依赖项上,删除它后代码可以工作。


0
投票

AppDelegate.swift
中删除以下代码解决了该问题。

if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
© www.soinside.com 2019 - 2024. All rights reserved.