Closed alexanderkhitev closed 7 years ago
I have the same problem.
Hi @caiovidaln ! Please see my answer on my question https://stackoverflow.com/questions/46391818/fcm-push-notifications-do-not-work-on-ios-11 It helped me, I'm currently testing, so that everything works as before, but unfortunately it will be necessary to wait until Apple confirms the new Build.
We have the same issue. Once the app goes into the background, no pushes are received at all.
Also not receiving push notifications with iOS 11 and latest firebaseMessaging 2.0.3, firebase 4.2.0. I have used the apps.sh script to test and i receive those notifications, but using the fcm id and sending through the console and I receive nothing.
I just did a drop in replace from previous version 1.2.1 and 3.11.1 (had to add one delegate function for token update).
I noticed from your code, you're not running the request for push authorization from application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions, perhaps you call it at later time?
I have similar issue. I updated to Firebase 4.2.0 and FirebaseMessaging 2.0.3, my issue is I'm not getting notification if I do request push notification at later time. (I'm doing soft request/custom dialog to check if user want to receive push notification, before using the system request). I was able to reproduce it from the quickstart project by adding a delay to the requestAuthorization for push. Here's my SO thread: https://stackoverflow.com/questions/46443189/firebase-messaging-not-sending-notification-when-push-notification-authenticatio
There is a known issue where the FCM token is not always being associated with the APNs device token if UIApplication.shared.registerForRemoteNotifications()
is not called early enough. This has already been fixed in the FirebaseInstanceID SDK, and should be coming out soon.
In the meantime, you can:
Lock your FirebaseInstanceID
pod to 2.0.0
in your Podfile, or
Ensure you're calling UIApplication.shared.registerForRemoteNotifications()
on app start, ideally before FirebaseApp.configure()
.
For testing, you can trigger a new FCM token by uninstall/reinstall your debug app on your device.
Got it. do you have any ETA when the version will be released? Tried to lock it, setting pod 'FirebaseInstanceID', '~> 2.0.0' , but it kept using the 2.0.3, How do I downgrade it?
@rsattar Thanks so much! Locking FirebaseInstanceID to 2.0.0 worked for me. @ordinaryman09 remove the arrow for an exact match: pod 'FirebaseInstanceID', '2.0.0'
@ordinaryman09 to specify exact versions, you should use '= 2.0.0'
. CocoaPods' ~>
specifier will use the most recent compatible version.
Both downgrading the FirebaseInstanceID and FirebaseMessaging and placing the UIApplication.shared.registerForRemoteNotifications() as the first thing in the didFinishLaunchingWithOptions still doesn't work and gives a similar error. Is there anything else I can do?
@10686142 try uninstalling the app and reinstalling with the code changes, to ensure that a new FCM token gets issued
Yeah somehow I still can't get it to work, but maybe I did something wrong since I am new to this. But maybe someone knows what it can be: I followed this tutorial: https://www.youtube.com/watch?v=_jy_Hlskmiw&t=710s Which came down to me delegate looking like this: https://github.com/douglasdevelops/PushNotificationSample/blob/master/PushNotificationSample/AppDelegate.swift
Is he maybe missing something is his explanation or am I missing something?
Thanks in advance!
Thanks @jtbh89 & @rsattar , I downgraded to 2.0.0 and it works for me now. @10686142 what messages are you seeing? Do you get the tokens?
2017-09-28 21:26:20.067218+0200 App Imperium News[1026:80671] [Firebase/Messaging][I-FCM002019] FIRMessaging received data-message, but FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented 2017-09-28 21:27:05.337971+0200 App Imperium News[1026:80673] TIC Read Status [5:0x0]: 1:57 2017-09-28 21:27:05.338807+0200 App Imperium News[1026:80673] TIC Read Status [5:0x0]: 1:57
Yeah I did also receive the token. And I got it to work earlier today that I could also see the push notification message in my debug log, but I always get that message about FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented
I got it to work finally guys! I added this piece of code: func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Messaging.messaging().apnsToken = deviceToken }
Beginners mistake I think, thanks for your help! @rsattar @richardliveraise
it works for me after downgrading to 2.0.0, thanks guys!
@rsattar Without using CocoaPods, how is it possible to downgrade to 2.0.0 to fix this? Can you provide a link to download the working framework(s)?
@candywriter you can download the tar.gz
from the link in the 2.0.0 podspec without using CocoaPods.
https://dl.google.com/dl/cpdc/9fe91bfb8772be4b/FirebaseInstanceID-2.0.0.tar.gz
@morganchen12 Thanks! Unfortunately manually replacing FirebaseInstanceID 2.0.3 with 2.0.0 produces a host of build errors.
I had no issues. Are you on the latest download besides that?
Try to set this, works for me:
Messaging.messaging().shouldEstablishDirectChannel = true
Sorry, my memories solution isn't really the solution. Message just arrived when app is active.
Downgrading FirebaseInstanceID to 2.0.0 did not work for me either.
However, adding this did work:
Messaging.messaging().apnsToken = deviceToken
in didRegisterForRemoteNotificationsWithDeviceToken
I'm confused why it works because this is only supposed to be in place if you have swizzling disabled, which I don't.
The solutions presented above did not work for me. I am using FirebaseInstanceID: 2.0.0, FirebaseMessaging: 2.0.0, FirebaseCore: 4.0.7, Firebase: 4.2.0 and FirebaseAnalytics: 4.0.3. Testing with iOS 11.
The message arrives with the application active, but it does not arrives when is in background.
extension AppDelegate: UNUserNotificationCenterDelegate {
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler:
@escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
func registerForPushNotifications(application: UIApplication) {
FirebaseApp.configure()
application.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
Messaging.messaging().delegate = self
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Notification: Unable to register for remote notifications: \(error.localizedDescription)")
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
NotificationCenterController.processMessage(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
NotificationCenterController.processMessage(userInfo)
completionHandler(.newData)
}
}
extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
print("Refresh Token")
}
// Receive data message on iOS 10 devices while app is in the foreground.
func application(received remoteMessage: MessagingRemoteMessage) {
NotificationCenterController.processMessage(remoteMessage.appData)
}
}
UPDATE Actually I noticed that the message is coming in the background, but it is only processed when the application is opened.
+1, using all new (Podfile.lock)
- Firebase/Core (4.2.0):
- FirebaseAnalytics (= 4.0.3)
- FirebaseCore (= 4.0.7)
- Firebase/Database (4.2.0):
- Firebase/Core
- FirebaseDatabase (= 4.0.3)
- Firebase/Messaging (4.2.0):
- Firebase/Core
- FirebaseMessaging (= 2.0.3)
Confirmed able to get push by APNS directly, not able to get push from firebase api/notification panel.
+1 to @farazq and overriding the swizzling method(s); even though I have set FirebaseAppDelegateProxyEnabled
to NO
in the Info.plist as the docs state, it seems to have no effect. (ie I am opting to NOT use method swizzling)
Using Cocoapods and FirebaseCore (4.0.7) FirebaseMessaging (2.0.3) for reference.
@lsalvoni I spent a few hours trying to understand wasn't working till i got to this thread.
The solution was moving my pods to this:
pod 'Firebase/Core', '4.0.4'
pod 'Firebase/Database', '4.0.4'
pod 'Firebase/Messaging', '4.0.4'
pod 'FirebaseInstanceID', '2.0.0'
I just also met the same problem. O my god, I spent about 2 hours on nothing trying to fix the problem with the certificates and provision profiles. But the only solution, that worked for me was to decrease 'FirebaseInstanceID' version to 2.0.0. After this notifications started to deliver on my iOS device.
Hey everyone, we released FirebaseInstanceID 2.0.4
today, which should be resolving a lot of the issues related to notification delivery. Please update to that if you're still having trouble.
Hi, I update to FirebaseInstanceID 2.0.4 but not working
Not working for me too. Still not receiving the notifications :(
@xeneka @o15a3d4l11s2 How are you sending the notification request? Firebase Notifications console? FCM HTTP API? If API, what parameters are you sending? Are you including the notification
key in the request?
I send notification with console of fireblade y with curl. the old version of app receive notification
import UIKit import Fabric import Crashlytics import UserNotifications import FirebaseCore import Firebase import FirebaseMessaging
fileprivate let viewActionIdentifier = "VIEW_IDENTIFIER" fileprivate let newsCategoryIdentifier = "NEWS_CATEGORY"
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Fabric.with([Crashlytics.self])
UNUserNotificationCenter.current().delegate = self
// Override point for customization after application launch.
registerForPushNotifications()
// 1
if let notification = launchOptions?[.remoteNotification] as? [String: AnyObject] {
// 2
let aps = notification["aps"] as! [String: AnyObject]
print(aps)
//_ = NewsItem.makeNewsItem(aps)
// 3
// (window?.rootViewController as? UITabBarController)?.selectedIndex = 1
}
FirebaseApp.configure()
connectToFcm()
Fabric.with([Crashlytics.self])
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
Messaging.messaging().disconnect()
print("Disconnected from FCM.")
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
////MARK: - Notification
// ojo fastlane sigh --development para generar certificado de develop
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
print("Device Token: \(token)")
let tokenFIR = Messaging.messaging().fcmToken
print("FIER TOKEN \(tokenFIR) fin")
}
/*func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print(userInfo)
}*/
func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let aps = userInfo["aps"] as! [String: AnyObject]
if aps["content-available"] as? Int == 1 {
/*let podcastStore = PodcastStore.sharedStore
podcastStore.refreshItems { didLoadNewItems in
completionHandler(didLoadNewItems ? .newData : .noData)
}*/
} else {
//_ = NewsItem.makeNewsItem(aps)
completionHandler(.newData)
}
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register: \(error)")
}
func registerForPushNotifications() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
(granted, error) in
print("Permission granted: \(granted)")
guard granted else { return }
let viewAction = UNNotificationAction(identifier: viewActionIdentifier,
title: "View",
options: [.foreground])
let newsCategory = UNNotificationCategory(identifier: newsCategoryIdentifier,
actions: [viewAction],
intentIdentifiers: [],
options: [])
UNUserNotificationCenter.current().setNotificationCategories([newsCategory])
self.getNotificationSettings()
}
}
func getNotificationSettings() {
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
print("Notification settings: \(settings)")
guard settings.authorizationStatus == .authorized else { return }
DispatchQueue.main.async{
UIApplication.shared.registerForRemoteNotifications()
}
}
}
// Firebase
func connectToFcm() {
Messaging.messaging().shouldEstablishDirectChannel = true
Messaging.messaging().connect { (error) in
if (error != nil) {
print("Unable to connect with FCM. \(error ?? "Sin error" as! Error)")
} else {
print("Connected to FCM.")
}
}
}
//Init session y login and pass in keychain
func loginWithKeychain() -> Bool{
let keychainManager = userLoginKeychainManager()
do {
let user = try keychainManager.recoverData()
if (!userManagerSession.getLogged()){
userManagerSession.sharedInstance.initWithLogin(login: user)
}
return true
}catch {
print("User no register")
return false
}
}
}
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
let aps = userInfo["aps"] as! [String: AnyObject]
/*if let newsItem = aps {
(window?.rootViewController as? UITabBarController)?.selectedIndex = 1
if response.actionIdentifier == viewActionIdentifier,
let url = URL(string: newsItem.link) {
//let safari = SFSafariViewController(url: url)
//window?.rootViewController?.present(safari, animated: true, completion: nil)
}
}*/
completionHandler()
}
}
extension AppDelegate : MessagingDelegate { func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) { print(messaging) }
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
print("mesaje")
}
// Receive data message on iOS 10 devices.
func application(received remoteMessage: MessagingRemoteMessage) {
print("%@", remoteMessage.appData)
}
}
@rsattar I am sending notifications through https://console.firebase.google.com. If I target a specific FCM token the notification is sent, but sending to a User Segment -> App does nothing.
I register the token manually
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
but this does not help.
I have tried using 'FirebaseInstanceID', '2.0.0'
with no success.
I have also moved UIApplication.shared.registerForRemoteNotifications()
on app start, before FirebaseApp.configure()
with no success.
Hi @rsattar,
I have exactly the same problem as what @o15a3d4l11s2 has. It would be great if we can hear from you soon.
Agree with all of the other posters: upgrading to Firebase 4.3 (and more specifically FirebaseInstanceID 2.0.4) does not fix the broken push notifications on iOS. Really poor effort by the Firebase team.
@candywriter are you saying 2.0.0 works for you and upgrading to 2.0.4 made it fail again?
In iOS11.0, there seems to be a problem with iOS itself in handling silent push notification. https://stackoverflow.com/questions/44796613/silent-pushes-not-delivered-to-the-app-on-ios-11
@keitaoouchi I don't believe this is the reason for not receiving the notifications. They say this issue mentioned in StackOverflow is already fixed. Even if it is not - I experience a different issue - I always receive the push notifications when targeting a single device and very rarely receive notifications when sending to a User Segment.
I'm also encountering the issue of @o15a3d4l11s2. I can receive push notifications by sending message to a single device, but almost nothing when using User Segment.
I wasn't receiving any notifications until I deleted the .p12 files from the firebase console and upload the .p8 file https://stackoverflow.com/questions/39672297/how-to-use-apples-new-p8-certificate-for-apns-in-firebase-console
@eduardoParadoja Thanks for the suggestion. I use APN Auth Key and not APN Push Certificate.
I am seeing the exact same issue as @o15a3d4l11s2.
We are using the console (https://console.firebase.google.com) to send notifications. If I target an individual device using the FCM token the notification is received. If I try to send to a User Segment the notification is not received. :shrug:
Firebase 4.3.0 , FirebaseAnalytics 4.0.4, FirebaseCore 4.0.8, FirebaseInstanceID 2.0.4, FirebaseMessaging 2.0.4
).p8
UIApplication.shared.registerForRemoteNotifications()
on app start in didFinishLaunchingWithOptions
and before FirebaseApp.configure()
Exact the same issue as @jacobmoncur. Even same versions of Firebase, .p8, Xcode 9
Same issue as @jacobmoncur's. We need to ask user give permission to push notification after FirebaseApp configuration.
How do I use this solution? fix is pod 'FirebaseInstanceID', "2.0.0"
HELP, PLEASE.
@ericklarac You add it on your Podfile
Pods: pod 'Firebase/Core', '4.0.4' pod 'Firebase/Database', '4.0.4' pod 'Firebase/Messaging', '4.0.4' pod 'FirebaseInstanceID', '2.0.0'
Getting
2017-10-11 00:45:28.181 Customer Connect[1964]
Any suggestions?
I use Firebase as a backend. I also use FCM as one of the provided features from Firebase. FCM worked well in iOS 10, but after switching to iOS 11, push notifications stopped coming to user devices, and I myself did not receive any push notifications sent from the cloud functions or the Notification section in the Firebase Console. How to fix this problem?
Update: I sent several push notifications from Firebase Notifcations, but they do not come.