简体   繁体   English

推送通知Firebase导致崩溃

[英]Push notification Firebase causes crash

We have some troubles with Firebase Push Notifications function since we using xCode 8 and OS 10. In our application, we asked user to enable push notification on second launch of app but after 10 seconds after the first (and next) launch, it crashes with this log : 由于我们使用xCode 8和OS 10,因此Firebase推送通知功能存在一些问题。在我们的应用程序中,我们要求用户在第二次启动应用程序时启用推送通知,但在第一次(和下一次)启动后10秒后,它会崩溃这个日志:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
'-[FIRInstanceIDConfig setAllowGCMRegistrationWithoutAPNSToken:]: unrecognized selector sent to instance 0x170207740'

We also try to disable swizzling but the problem occurred again. 我们还尝试禁用调配,但问题再次发生。

Can someone tell us where we are going wrong? 有人能告诉我们哪里出错了吗?

Firebase AppDelegate Code : Firebase AppDelegate代码:

#pragma mark - Notification
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    UALog(@"success to register notification");
#ifdef DEBUG
    [[FIRInstanceID instanceID] setAPNSToken:deviceToken
                                        type:FIRInstanceIDAPNSTokenTypeSandbox];
#else
    [[FIRInstanceID instanceID] setAPNSToken:deviceToken
                                        type:FIRInstanceIDAPNSTokenTypeProduction];
#endif
}

Push notification asked : 推送通知问:

if ([popUpViewController isKindOfClass:[GSPushNotificationsPopupViewController class]]) {
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:NSUD_ALREADY_DISPLAYED_NOTIF_MESSAGE];
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
        UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } else {
        // iOS 10 or later
        UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
        [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {

        }];

        // For iOS 10 display notification (sent via APNS)
        [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
        // For iOS 10 data message (sent via FCM)
        [[FIRMessaging messaging] setRemoteMessageDelegate:self];
    }
}

Have you added your app's other linker flags to -ObjC ? 您是否已将应用程序的其他链接器标志添加-ObjC You can do this by clicking: Project Name -> Build Settings -> Other Linker Flags 您可以通过单击:项目名称 - >构建设置 - >其他链接器标志来完成此操作

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM