Push notifications
With FirebaseInstanceID 2.0.3 push notifications don't work, but with 2.0.0 they do.
Xcode 9 cant make it work also! tried messaging 2.0.0, 2.0.2 and 2.0.3
Can you both include more information on how you've set up Messaging?
This solved the problem
-(void)registerForPush
{
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
if(granted && !error )
{
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
[[PushManager sharedInstance] registerNotificationCategories];
if([FIRApp defaultApp] == nil)
{
[FIRApp configure];
}
[FIRMessaging messaging].delegate = self;
DDLogDebug( @"Push registration success." );
});
}
else
{
DDLogDebug( @"Push registration FAILED" );
}
}];
}
Before this blokc was outside
if([FIRApp defaultApp] == nil)
{
[FIRApp configure];
}
[FIRMessaging messaging].delegate = self;
like this
-(void)registerForPush
{
if([FIRApp defaultApp] == nil)
{
[FIRApp configure];
}
[FIRMessaging messaging].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
if(granted && !error )
{
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
[[PushManager sharedInstance] registerNotificationCategories];
DDLogDebug( @"Push registration success." );
});
}
else
{
DDLogDebug( @"Push registration FAILED" );
}
}];
}
it worked with XCode 8 and lower versions. There is some thread thing going on maybe....
There is a bug which has been fixed internally but hasn't been released yet, that is likely causing the issue.
For now, as a workaround you should always just call [[UIApplication sharedApplication] registerForRemoteNotifications]; as early as possible (this does not create a user permissions dialog, and should always give you an APNs token).
thx
Also fixed for me, thanks !
It's not fixing it for me. The messages don't get delivered if the app is in the background on iOS 11.
@berlininsomniac Here is my fix in Swift if it can help you :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// [START set_messaging_delegate]
Messaging.messaging().delegate = self
// [END set_messaging_delegate]
// Register for remote notifications. This shows a permission dialog on first run, to
// show the dialog at a more appropriate time move this registration accordingly.
// [START register_for_notifications]
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
// [END register_for_notifications]
FirebaseApp.configure()
return true
}
@berlininsomniac Not receiving messages in the background usually indicates an issue with the app configuration for APNs (i.e. check if application:didRegisterForRemoteNotificationsWithDeviceToken: is being called in your app delegate), or perhaps you are making a non-APNs request to the FCM API (i.e. if you are not sending a notification payload, and not including content_available=1).
There is also a known issue in iOS 11.0 where silent notifications (content_available=1) are arriving on the device, but not actually being delivered to the app.
@rsattar It doesn't work anymore, without changing my code ... Waiting the fix release .... Thanks
@Aurazion Confirming that [email protected] is fully operational when you add application.registerForRemoteNotifications() as the first line in didFinishLaunchingWithOptions.
Waiting for the final fix though, kinda ugly solution.
FWIW, if you're locking temporarily to 2.0.0 you don't need to also call application.registerForRemoteNotifications() on app start.
I can confirm that downgrading FirebaseInstanceID to 2.0.0 reenables pushes on iOS 11.
How to downgrade the FirebaseInstanceID?
I am just adding
pod 'Firebase/Core', '4.0.1'
pod 'Firebase/Messaging'
if I do
pod 'Firebase/Core', '4.0.1'
pod 'Firebase/Messaging', '2.0.0'
pod 'Firebase/InstanceID', '2.0.0'
Which doesn't allow me to install pod.
Any idea?
Try pod 'FirebaseInstanceID', '2.0.0'
pod 'FirebaseInstanceID', '2.0.0', fixed the problem for me. Thanks for everyone in this feed. Saved my day :)
Same for me with pod 'FirebaseInstanceID', '2.0.0'
Thanks
Fix released today in Firebase 4.3.0, FirebaseMessaging 2.0.4, and FirebaseInstanceID 2.0.4
I'm hitting this same issue today on: Using Firebase (4.6.0) Using FirebaseAnalytics (4.0.5) Using FirebaseAuth (4.3.2) Using FirebaseCore (4.0.11) Using FirebaseDatabase (4.1.1) Using FirebaseInstanceID (2.0.6) Using FirebaseMessaging (2.0.6)
Function boringssl_context_get_peer_sct_list: line 1757 received sct extension length is less than sct data length
Indeed, it came back again.
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Can't handle server close in non-started state.'