Flutter应用在iOS上接收Airship推送通知后崩溃。

huangapple go评论82阅读模式
英文:

Flutter App crashes on iOS after receiving push notification from Airship

问题

我们最近在iOS上遇到了应用程序崩溃的问题(在Android上正常工作),在接收和/或点击Airship的推送通知后出现了问题,使用了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
英文:

We are recently experiencing app crashes only on iOS (on Android it works fine) after receiving and/or clicking push notification from Airship with Flutter.

The error we're getting looks like this:

-[__NSCFType userNotificationCenter:willPresentNotification:withCompletionHandler:]: unrecognized selector sent to instance 0x283cad3b0
*** Terminating app due to uncaught exception &#39;NSInvalidArgumentException&#39;, reason: &#39;-[__NSCFType userNotificationCenter:willPresentNotification:withCompletionHandler:]: unrecognized selector sent to instance 0x283cad3b0&#39;
*** 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 = &#39;com.apple.main-thread&#39;, stop reason = signal SIGABRT
    frame #0: 0x00000001d7e9a558 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
-&gt;  0x1d7e9a558 &lt;+8&gt;:  b.lo   0x1d7e9a578               ; &lt;+40&gt;
    0x1d7e9a55c &lt;+12&gt;: pacibsp 
    0x1d7e9a560 &lt;+16&gt;: stp    x29, x30, [sp, #-0x10]!
    0x1d7e9a564 &lt;+20&gt;: mov    x29, sp

Dependencies in 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

答案1

得分: 0

问题出在firebase_messaging依赖上,移除后代码可以正常工作。

英文:

The problem was with the firebase_messaging dependency, after removing it the code works.

答案2

得分: 0

AppDelegate.swift 中移除以下代码修复了该问题。

if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
英文:

Removing the following code from AppDelegate.swift fixed the issue.

if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}

huangapple
  • 本文由 发表于 2023年6月1日 16:12:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379899.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定