我的应用尝试使用Firebase
远程通知,我遵循了Firebase指南。现在,我的应用程序在AppDelegate
崩溃,我试图在其中设置Firebase
消息传递的委托。
这是代码
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
在第二行中,它崩溃并显示以下崩溃消息:
+ [FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]:无法识别的选择器已发送给类0x10ef2a538
*由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因: '+ [FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: 无法识别的选择器发送到类0x10ef2a538' * 第一个调用堆栈:(0 CoreFoundation 0x00000001116671e6 exceptionPreprocess + 294 1 libobjc.A.dylib
0x0000000110cfc031 objc_exception_throw + 48 2 CoreFoundation
0x00000001116e86c4 + [NSObject(NSObject)didNotRecognizeSelector:] + 132 3 CoreFoundation 0x00000001115e9898 ___ forwarding _ + 1432 4 CoreFoundation 0x00000001115e9278 _CF_forwarding_prep_0 + 120 5 MobilePro开发
0x000000010ed09af3-[FIRInstanceIDCheckinStore [cachedCheckinPreferences] + 407 6 MobilePro Dev
0x000000010ed0d73a-[FIRInstanceID存储resetCredentialsIfNeeded] + 145 7 MobilePro开发0x000000010ed0d230 -[FIRInstanceIDStore initWithCheckinStore:tokenStore:delegate:] + 174 8 MobilePro Dev 0x000000010ed0d154 -[FIRInstanceIDStore initWithDelegate:] + 142 9 MobilePro Dev 0x000000010ed10acc-[FIRInstanceIDTokenManager init] + 105 10 MobilePro Dev 0x000000010ed022ae-[FIRInstanceID setupTokenManager] + 50 11 MobilePro开发
0x000000010ed0225c-[FIRInstanceID开始] + 90 12 libdispatch.dylib 0x0000000114c4f7ec _dispatch_client_callout + 8 13 libdispatch.dylib 0x0000000114c50d64 dispatch_once_f + 285 14 MobilePro Dev
0x000000010ecfefac + [FIRInstanceID instanceID] + 45 15 MobilePro开发 0x000000010ed26a6a-[FIRMessaging initPrivately] + 38 16 MobilePro 开发人员0x000000010ed26939 25+ [FIRMessaging 消息传递] _block_invoke + 41 17 libdispatch.dylib
0x0000000114c4f7ec _dispatch_client_callout + 8 18 libdispatch.dylib 0x0000000114c50d64 dispatch_once_f + 285 19 MobilePro Dev
0x000000010ed2690d + [FIRM消息传递消息] + 45 20 MobilePro Dev
0x000000010eaa9ac3-[AppDelegate 应用程序:didFinishLaunchingWithOptions:] + 323 21 UIKit
0x00000001128d96fb-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 278 22 UIKit 0x00000001128db172 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4123 23 UIKit 0x00000001128e05cb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1677 24 UIKit 0x0000000112ca2f7e __111-[__ UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] _ block_invoke + 866 25 UIKit 0x0000000113075a39 + [_ UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153 26 UIKit 0x0000000112ca2bba -[__ UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236 27 UIKit 0x0000000112ca33db -[__ UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 675 28 UIKit
0x0000000113614614 __82-[_ UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] _ block_invoke + 299 29 UIKit 0x00000001136144ae-[_ UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433 30 UIKit 0x00000001132f875d __125-[_ UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] _ block_invoke + 221 31 UIKit 0x00000001134f34b7 _performActionsWithDelayForTransitionContext + 100 32 UIKit 0x00000001132f8627-[_ UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223 33 UIKit 0x00000001130750e0-[_ UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392 34 UIKit 0x00000001128deeac -[UIApplication工作区:didCreateScene:withTransitionContext:完成:] + 515 35 UIKit 0x0000000112eb1bcb -[UIApplicationSceneClientAgent场景:didInitializeWithEvent:完成:] + 361 36 FrontBoardServices 0x00000001176452f3-[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 331 37 FrontBoardServices 0x000000011764dcfa __56- [FBSWorkspace客户端:handleCreateScene:withCompletion:] _ block_invoke_2 + 225 38 libdispatch.dylib 0x0000000114c4f7ec _dispatch_client_callout + 8 39 libdispatch.dylib 0x0000000114c54db8 _dispatch_block_invoke_direct + 592 40 FrontBoardServices 0x0000000117679470 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24 41 FrontBoardServices 0x000000011767912e -[FBSSerialQueue _performNext] + 439 42 FrontBoardServices 0x000000011767968e-[FBSSerialQueue _performNextFromRunLoopSource] + 45 43 CoreFoundation 0x0000000111609bb1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 44 CoreFoundation 0x00000001115ee4af __CFRunLoopDoSources0 + 271 45 CoreFoundation 0x00000001115eda6f __CFRunLoopRun + 1263 46 CoreFoundation
0x00000001115ed30b CFRunLoopRunSpecific + 635 47 GraphicsServices
0x000000011779ca73 GSEventRunModal + 62 48 UIKit
0x00000001128e2057 UIApplicationMain + 159 49 MobilePro开发
0x000000010eac56cf main + 111 50 libdyld.dylib
0x0000000114ccc955开始+ 1 51 ???
0x0000000000000001 0x0 +1)libc ++ abi.dylib:终止于 类型为NSException的未捕获异常
答案 0 :(得分:0)
调用委托时,必须确保已编写该委托的所有必需方法。
检查在您的Appdelegate中调用了以下方法。
index household carID waypoint absent
497 201248 2 from home 15
498 201248 2 18
499 201248 2 to home 19 4
500 201248 1 from home 10
501 201248 1 to home 10
502 201248 1 19
503 201248 1 to home 0 14
504 201248 2 from home 8
505 201248 2 9
506 201248 2 to home 9 11 (because the final end time is 19:00 see upper table)
或确保在您的Appdelegate中编写 FIRMessagingDelegate
-(void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken
{
}
答案 1 :(得分:0)
您需要更改Firebase配置方法。
命名为
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 42.0), dispatch_get_main_queue(), ^{
[FIRApp configure];
});
它将解决您的问题。
答案 2 :(得分:0)
import FirebaseMessaging
FirebaseApp.configure()
Messaging.messaging().delegate = self
// MARK:-消息代理方法..............................
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
let token = Messaging.messaging().fcmToken
print("FCM token: \(token ?? "")")
}
答案 3 :(得分:0)
如果您不使用Pod,则必须为目标添加objC链接器标志。
从文档中:
”不使用CocoaPods进行集成 如果您不想使用Cocoapods,您仍然可以通过直接导入框架来利用Firebase SDK。
下载框架SDK zip。这是一个大约1GB的文件,可能需要一些时间才能下载。
解压缩文件,然后查看要包含在应用程序中的框架的自述文件。
在目标的构建设置的“其他链接器设置”中添加ObjC链接器标志。”
链接: https://firebase.google.com/docs/ios/setup https://developer.apple.com/library/archive/qa/qa1490/_index.html