У нас есть некоторые проблемы с функцией Push-уведомления Firebase, поскольку мы используем xCode 8 и OS 10. В нашем приложении мы попросили пользователя включить push-уведомление при втором запуске приложения, но через 10 секунд после первого (и следующий) запуск, он падает с этим журналом:Push-уведомление Firebase вызывает сбой
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[FIRInstanceIDConfig setAllowGCMRegistrationWithoutAPNSToken:]: unrecognized selector sent to instance 0x170207740'
Мы также стараемся, чтобы отключить swizzling, но проблема возникла снова.
Может ли кто-нибудь сказать нам, где мы ошибаемся?
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
}
уведомление Нажмите спросил:
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];
}
}
Также с этой проблемой. Вы выяснили решение? – Tander