I'm trying to subscribe the user to a topic named after his phone number (only numbers) and at installation it works perfectly, but after running the app once again it fails to subscribe him into that topic and he don't get notifications anymore.
This is the error i'm getting:
The operation couldn鈥檛 be completed. (com.google.fcm error 0.)
And another error i'm getting is:
[Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
Implement the basic code of Cloud Messaging.
AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UIApplication.shared.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
}
Main ViewController (it belongs to a different storyboard after logging in to the app):
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let center = UNUserNotificationCenter.current()
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
center.requestAuthorization(options: authOptions) { granted, error in
InstanceID.instanceID().instanceID { (result, error) in
if let error = error {
print("Error fetching remote instance ID: \(error)")
} else {
center.delegate = self
}
}
}
if let userPhone = UserDefaults.standard.string(forKey: "userPhone") {
Messaging.messaging().subscribe(toTopic: userPhone) { error in
if error != nil {
print("Subscription error: \(error?.localizedDescription ?? "")")
} else {
print("Subscribed to topic \(userPhone)")
}
}
}
}
Is your FCM token changed the second time app starts? I'm wondering if it's a similar issue like #2438
I am receiving the same issue as described above. On the first run, everything works correctly but on the second run, I receive the same errors described above. I'm using firebase version 5.20.2 with firebase messaging version 3.5.0 and have been reading issue #2438 , from my error logs I don't see FCM token changing on the second run of the app. It also seems when I receive these "failed to subscribe errors" my push notifications stop working altogether also. I provided an error log with debug logging enabled.
Error log
I created a new issue with debug log attached #2903
@stshelton From your log, you are not sending me the full context, like "topic subscription request". Also some of the logs seem missing. Can you send the full log of anything InstanceID and Messaging Log related so I can get a better idea on why the request was failing? Thank you!
I searched instanceID and Messaging within debug window. If you want all of debug window I can copy and paste it, it just logged a lot of info that I feel like u don't need. I was trying to save all of log but i couldnt find a way.
instanceID:
2019-04-26 16:22:26.888478-0400 HummingBiird_App_Dev[1687:320114] 5.20.0 - [Firebase/InstanceID][I-IID023000] Info is not found in Keychain. OSStatus: -25300. Keychain query: {
2019-04-26 16:22:26.894300-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/InstanceID][I-IID023000] Info is not found in Keychain. OSStatus: -25300. Keychain query: {
2019-04-26 16:22:26.894400-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/InstanceID][I-IID023000] Info is not found in Keychain. OSStatus: -25300. Keychain query: {
2019-04-26 16:22:26.894473-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/InstanceID][I-IID009000] No keypair info is found with tag com.google.iid-|K|
13-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/InstanceID][I-IID009006] There's no legacy keypair so no need to do migration.
messaging
2019-04-26 16:22:26.919415-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/Messaging][I-FCM002000] FIRMessaging library version 3.5.0
2019-04-26 16:22:26.919876-0400 HummingBiird_App_Dev[1687:320118] 5.20.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
2019-04-26 16:22:28.110298-0400 HummingBiird_App_Dev[1687:320133] 5.20.0 - [Firebase/Messaging][I-FCM012019-04-26 16:22:28.110626-0400 HummingBiird_App_Dev[1687:320133] 5.20.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=fxg9HTNNvEU:2019-04-26 16:22:28.250350-0400 HummingBiird_App_Dev[1687:320123] 5.20.0 - [Firebase/Messaging][I-FCM017002] Invalid registration response Error=INVALID_PARAMETERS
2019-04-26 16:22:28.250630-0400 HummingBiird_App_Dev[1687:320123] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
2019-04-26 16:22:28.252865-0400 HummingBiird_App_Dev[1687:320121] 5.20.0 - [Firebase/Messaging][I-FCM017002] Invalid registration response Error=INVALID_PARAMETERS
2019-04-26 16:22:28.252944-0400 HummingBiird_App_Dev[1687:320121] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
topic
Topic subscription request: sender=fxg9HTNNvEU:APA91bFXCtRjCz1Bdjua9SI9lPQ1AmfWVRVuBPlf2dVX6btKqvbbnLgpz0s90hDwWv0azGEfqpC1NMm8lKQPsdRpOLngjHDHYEp8eGmm4bgx-Frr3t_iTBLrRqRPDjfUbm6P6i3cCjv1&app=com.HummingbiirdHoldingCompany.HummingBiird-App-DEV&device=5264296442884229290&app_ver=2.6&X-gcm.topic=/topics/accountSupport&X-scope=/topics/accountSupport
2019-04-26 16:22:28.110626-0400 HummingBiird_App_Dev[1687:320133] 5.20.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=fxg9HTNNvEU:APA91bFXCtRjCz1Bdjua9SI9lPQ1AmfWVRVuBPlf2dVX6btKqvbbnLgpz0s90hDwWv0azGEfqpC1NMm8lKQPsdRpOLngjHDHYEp8eGmm4bgx-Frr3t_iTBLrRqRPDjfUbm6P6i3cCjv1&app=com.HummingbiirdHoldingCompany.HummingBiird-App-DEV&device=5264296442884229290&app_ver=2.6&X-gcm.topic=/topics/promoTips&X-scope=/topics/promoTips
2019-04-26 16:22:28.250630-0400 HummingBiird_App_Dev[1687:320123] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
2019-04-26 16:22:28.252944-0400 HummingBiird_App_Dev[1687:320121] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
It seems if I downgrade to firebase version 5.15.0. Push notifications/topics are working as intended, but only if I delete app and redownload it. Which there are some live users that have this version of the app and I would like to be able to fix push notifications with an update that doesn't require the user to delete app and redownload.
I'm also experiencing the same issue. Hope the following info is helpful:
Xcode version: 10.2.1 (10E1001)
Firebase SDK version: 5.20.2
Firebase Component: Messaging
Component version: 3.5.0
Instead of pasting my full logs, I'm only pasting what I believe to be the relevant parts.
2019-04-28 01:07:52.243640-0700 Puppr-DEV[22812:10048118] 5.20.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=cngDGp5-piY:APA91bEajzOlWdYdbtZODQ_ixQGmJj5m_hnoAgbA58A2qZcKf8J_A2LNnQ3xQM0twgwJ8pF35iddCPPXkuX3ePbDYrOFGcF1yWYxfNuUlu0SGbkiwf7HmR11Q_LGvLWbyA8BSeiHRu9D&app=com.chinandcheeks.dogtrainer&device=5669145430566317485&app_ver=0.1&X-gcm.topic=/topics/timedSales&X-scope=/topics/timedSales
2019-04-28 01:07:52.932493-0700 Puppr-DEV[22812:10048126] 5.20.0 - [Firebase/Messaging][I-FCM004003] Successfully subscribed to topic /topics/timedSales
2019-04-28 01:08:58.411008-0700 Puppr-DEV[22817:10048791] 5.20.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=cngDGp5-piY:APA91bEajzOlWdYdbtZODQ_ixQGmJj5m_hnoAgbA58A2qZcKf8J_A2LNnQ3xQM0twgwJ8pF35iddCPPXkuX3ePbDYrOFGcF1yWYxfNuUlu0SGbkiwf7HmR11Q_LGvLWbyA8BSeiHRu9D&app=com.chinandcheeks.dogtrainer&device=4851790658297917259&app_ver=0.1&X-gcm.topic=/topics/timedSales&X-scope=/topics/timedSales
2019-04-28 01:08:58.606766-0700 Puppr-DEV[22817:10048789] 5.20.0 - [Firebase/Messaging][I-FCM017002] Invalid registration response Error=INVALID_PARAMETERS
2019-04-28 01:08:58.606881-0700 Puppr-DEV[22817:10048789] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
2019-04-28 01:10:19.412870-0700 Puppr-DEV[22821:10049215] 5.20.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=cngDGp5-piY:APA91bEajzOlWdYdbtZODQ_ixQGmJj5m_hnoAgbA58A2qZcKf8J_A2LNnQ3xQM0twgwJ8pF35iddCPPXkuX3ePbDYrOFGcF1yWYxfNuUlu0SGbkiwf7HmR11Q_LGvLWbyA8BSeiHRu9D&app=com.chinandcheeks.dogtrainer&device=5372838138733384695&app_ver=0.1&X-gcm.topic=/topics/timedSales&X-scope=/topics/timedSales
2019-04-28 01:10:19.612324-0700 Puppr-DEV[22817:10048789] 5.20.0 - [Firebase/Messaging][I-FCM017002] Invalid registration response Error=INVALID_PARAMETERS
2019-04-28 01:10:19.613271-0700 Puppr-DEV[22817:10048789] 5.20.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"
Notice that the device param value changes with every app start.
Here's what my debug logs look like after downgrading to Firebase SDK version 5.15.0:
2019-04-28 01:32:31.005339-0700 Puppr-DEV[22848:10055628] 5.15.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=eo6vuaxmLcU:APA91bHHHlomRbZz-L7x7pITgzAJfzH30Ctfwf3WDOJWPqEDIzVbxbTiINA7myYjSUrR7CQfK_IZSxtLhpDffM-xra6O3WBLCqY94JTBaG704nqTZOdqlCsJaWOVxWE2-ickHqGEdRSO&app=com.chinandcheeks.dogtrainer&device=5280035528981645835&app_ver=0.1&X-gcm.topic=/topics/timedSales&X-scope=/topics/timedSales
2019-04-28 01:32:31.784553-0700 Puppr-DEV[22848:10055627] 5.15.0 - [Firebase/Messaging][I-FCM004003] Successfully subscribed to topic /topics/timedSales
2019-04-28 01:33:14.106642-0700 Puppr-DEV[22856:10056240] 5.15.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=eo6vuaxmLcU:APA91bHHHlomRbZz-L7x7pITgzAJfzH30Ctfwf3WDOJWPqEDIzVbxbTiINA7myYjSUrR7CQfK_IZSxtLhpDffM-xra6O3WBLCqY94JTBaG704nqTZOdqlCsJaWOVxWE2-ickHqGEdRSO&app=com.chinandcheeks.dogtrainer&device=5280035528981645835&app_ver=0.1&X-gcm.topic=/topics/timedSales&X-scope=/topics/timedSales
2019-04-28 01:33:14.888842-0700 Puppr-DEV[22856:10056239] 5.15.0 - [Firebase/Messaging][I-FCM004003] Successfully subscribed to topic /topics/timedSales
In this case, the device param values are remaining consistent across multiple app starts.
Let me know if there are any other logs you'd like me to provide. In the meantime, I'll be downgrading to v5.15.0 to work around the issue.
Looks like the parameters are consistent, I will forward the request to the team and get back to you soon.
I also got this. Why is it not fixed?
i'm having the same issue, downgrading to v5.15.0 worked
pod 'Firebase/Core', '~> 5.15.0'
pod 'Firebase/Messaging', '~> 5.15.0'
Notice your device ID has changed, this should be the same issue that one of our previous release cause your client to have a bad checkin. https://github.com/firebase/firebase-ios-sdk/pull/2860 should fix the issue, and it will be in the next release.
In the meantime, you can either patch #2860 or call deleteIDWithHandler: once(and only once) to clear your corrupted checkin data.
Most helpful comment
Looks like the parameters are consistent, I will forward the request to the team and get back to you soon.