Firebase-ios-sdk: Complition handler InstanceID.instanceID().instanceID is not called after FirebaseApp.configure()

Created on 26 Feb 2019  路  21Comments  路  Source: firebase/firebase-ios-sdk

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.1 (10B61)
  • Firebase SDK version: 5.17.0
  • Firebase Component: Core
  • Component version: 5.3.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

following is in my pod file of a new project

  pod 'Firebase/Core', '~> 5.17.0'

Relevant Code:

Completion handler NEVER get called. Nor result or error

import Firebase
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        InstanceID.instanceID().instanceID { (result, error) in
                // Not called
        }

        return true
    }
}

But if add delay, like that:

        DispatchQueue.main.asyncAfter(deadline: (.now() + 0.3)) {
            InstanceID.instanceID().instanceID { (result, error) in
                // Get called
            }
        }

All is work

instanceid

Most helpful comment

Thanks for the response. It now works. I managed to set the version for each dependency and my Podfile look like this now.

pod 'Firebase/Core', '5.19.0'
pod 'FirebaseMessaging', '3.4.0'
pod 'FirebaseInstanceID', '3.8.0'

All 21 comments

Thanks for the report, I'll try to reproduce this shortly and report back here. cc @chliangGoogle

@MamuninaNV I'm unable to reproduce the issue. Are you able to add a print statement and share the logs from the console in Xcode? A project that I can drag my own GoogleService-Info.plist into would work as well.

TestFirebase.zip
I'm uploading a project.
When you first time to launch the project on your device or simulator you can see the issue (only first time). If project is relaunch on device (or on simulator) you will not see the issue. This issue is occur in first launch on device (simulator)

2019-02-26 19:25:49.060474+0300 TestFirebase[11218:529690]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-02-26 19:25:49.093771+0300 TestFirebase[11218:529628] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-02-26 19:25:49.259003+0300 TestFirebase[11218:529692] 5.17.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50600000 started
2019-02-26 19:25:49.259263+0300 TestFirebase[11218:529692] 5.17.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2019-02-26 19:25:49.461358+0300 TestFirebase[11218:529708] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fdf46402220] get output frames failed, state 8196
2019-02-26 19:25:49.461619+0300 TestFirebase[11218:529708] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fdf46402220] get output frames failed, state 8196
2019-02-26 19:25:49.462384+0300 TestFirebase[11218:529708] TIC Read Status [1:0x0]: 1:57
2019-02-26 19:25:49.462519+0300 TestFirebase[11218:529708] TIC Read Status [1:0x0]: 1:57
2019-02-26 19:26:04.115245+0300 TestFirebase[11218:529830] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fdf46409690] get output frames failed, state 8196
2019-02-26 19:26:04.115453+0300 TestFirebase[11218:529830] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fdf46409690] get output frames failed, state 8196
2019-02-26 19:26:04.115860+0300 TestFirebase[11218:529830] TIC Read Status [4:0x0]: 1:57
2019-02-26 19:26:04.115996+0300 TestFirebase[11218:529830] TIC Read Status [4:0x0]: 1:57
2019-02-26 19:26:04.240042+0300 TestFirebase[11218:529691] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x7fdf46413d50] get output frames failed, state 8196
2019-02-26 19:26:04.240221+0300 TestFirebase[11218:529691] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x7fdf46413d50] get output frames failed, state 8196
2019-02-26 19:26:04.240740+0300 TestFirebase[11218:529691] TIC Read Status [5:0x0]: 1:57
2019-02-26 19:26:04.240959+0300 TestFirebase[11218:529691] TIC Read Status [5:0x0]: 1:57

Ah got it, thanks! I found the reason why this is happening:

https://github.com/firebase/firebase-ios-sdk/blob/7cc0a9bc9881c858fdfc5cc06bcb008f4b193b2f/Firebase/InstanceID/FIRInstanceID.m#L899

It looks like self.isFetchingDefaultToken is true because it's being fetched already as part of the startup of InstanceID when there's no token available. My first thought would be to check if this handler is the same as the one used previously and use both handlers that have registered, but that may be quite a large change and there could be something better.

@chliangGoogle can you please take a look?

Thanks again @MamuninaNV for catching this.

Reassigning to @maksymmalyhin who has some more bandwidth to look at it.

Fixed in #2559

Thanks you all :)

@maksymmalyhin Would you happen to know when this will be released?

@falipate It should be available in the next version.

Added to the 5.20.0 milestone.

Hello,

do you know the version of the library that corrects this problem?
I still have this problem with the pod updated :

Using Firebase (5.20.1)
Using FirebaseABTesting (2.0.0)
Using FirebaseAnalytics (5.8.0)
Using FirebaseAnalyticsInterop (1.2.0)
Using FirebaseCore (5.4.1)
Using FirebaseInAppMessaging (0.13.0)
Using FirebaseInAppMessagingDisplay (0.13.1)
Using FirebaseInstanceID (3.8.1)
Using FirebaseMessaging (3.5.0)
Using FirebasePerformance (2.2.4)
Using FirebaseRemoteConfig (3.1.0)

thanks

Hello ,

I still have same issue my pod version

Using Firebase (5.20.1)
Using FirebaseAnalytics (5.8.0)
Using FirebaseAnalyticsInterop (1.2.0)
Using FirebaseCore (5.4.1)
Using FirebaseDynamicLinks (3.4.3)
Using FirebaseInstanceID (3.8.1)
Using FirebaseMessaging (3.5.0)

@ahmedAlmasri I had have backup my pod file and i restore it on an older version

@ahmedAlmasri @AmandineDB I am not able to reproduce the issue with the originally provided test project and steps. Would you be able to provide updated ones please? If the steps are different, it may make sense to create a separate ticket. Thanks.

@maksymmalyhin The same steps , But do not occur every time

hello @maksymmalyhin,

not exactly the same steps.

I call
FirebaseApp.configure() on my
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

and after a login I ask to register for APNS

`func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken

    InstanceID.instanceID().instanceID(handler: { (result, error) in

//not enter here
if let error = error {

                print("Error fetching remote instance ID: \(error)")

            } else if let result = result {

            }
        })

}`

so I had have backup my pod file and i restore it on an older version

and all is ok

Have a good day

hi @AmandineDB. I'm experiencing the same issue as you. Could you please provide the version you rolled back to?

this is an extract of my podfile.lock :

  • Firebase/Core (5.19.0):

    • Firebase/CoreOnly

    • FirebaseAnalytics (= 5.8.0)

    • Firebase/CoreOnly (5.19.0):

    • FirebaseCore (= 5.4.0)

    • Firebase/InAppMessagingDisplay (5.19.0):

    • Firebase/CoreOnly

    • FirebaseInAppMessagingDisplay (= 0.13.1)

    • Firebase/Messaging (5.19.0):

    • Firebase/CoreOnly

    • FirebaseMessaging (= 3.4.0)

    • Firebase/Performance (5.19.0):

    • Firebase/Core

    • FirebasePerformance (= 2.2.4)

    • FirebaseABTesting (2.0.0):

    • FirebaseCore (~> 5.0)

    • Protobuf (~> 3.5)

    • FirebaseAnalytics (5.8.0):

    • FirebaseCore (~> 5.4)

    • FirebaseInstanceID (~> 3.8)

    • GoogleAppMeasurement (= 5.8.0)

    • GoogleUtilities/AppDelegateSwizzler (~> 5.2)

    • GoogleUtilities/MethodSwizzler (~> 5.2)

    • GoogleUtilities/Network (~> 5.2)

    • "GoogleUtilities/NSData+zlib (~> 5.2)"

    • nanopb (~> 0.3)

    • FirebaseAnalyticsInterop (1.2.0)

    • FirebaseCore (5.4.0):

    • GoogleUtilities/Environment (~> 5.2)

    • GoogleUtilities/Logger (~> 5.2)

    • FirebaseInAppMessaging (0.13.0):

    • FirebaseAnalytics

    • FirebaseAnalyticsInterop

    • FirebaseCore

    • FirebaseInstanceID

    • FirebaseInAppMessagingDisplay (0.13.1):

    • FirebaseCore

    • FirebaseInAppMessaging (>= 0.12.0)

    • FirebaseInstanceID (3.8.0):

    • FirebaseCore (~> 5.2)

    • GoogleUtilities/Environment (~> 5.2)

    • GoogleUtilities/UserDefaults (~> 5.2)

    • FirebaseMessaging (3.4.0):

    • FirebaseAnalyticsInterop (~> 1.1)

    • FirebaseCore (~> 5.2)

    • FirebaseInstanceID (~> 3.6)

    • GoogleUtilities/Environment (~> 5.3)

    • GoogleUtilities/Reachability (~> 5.3)

    • GoogleUtilities/UserDefaults (~> 5.3)

    • Protobuf (~> 3.1)

    • FirebasePerformance (2.2.4):

    • FirebaseAnalytics (~> 5.8)

    • FirebaseInstanceID (~> 3.8)

    • FirebaseRemoteConfig (~> 3.1)

    • GoogleToolboxForMac/Logger (~> 2.1)

    • "GoogleToolboxForMac/NSData+zlib (~> 2.1)"

    • GoogleUtilities/ISASwizzler (~> 5.2)

    • GoogleUtilities/MethodSwizzler (~> 5.2)

    • GTMSessionFetcher/Core (~> 1.1)

    • Protobuf (~> 3.5)

    • FirebaseRemoteConfig (3.1.0):

    • FirebaseABTesting (~> 2.0)

    • FirebaseAnalytics (~> 5.3)

    • FirebaseCore (~> 5.1)

    • FirebaseInstanceID (~> 3.3)

    • GoogleUtilities/Environment (~> 5.2)

    • "GoogleUtilities/NSData+zlib (~> 5.2)"

    • Protobuf (~> 3.5)

Thanks for the response. It now works. I managed to set the version for each dependency and my Podfile look like this now.

pod 'Firebase/Core', '5.19.0'
pod 'FirebaseMessaging', '3.4.0'
pod 'FirebaseInstanceID', '3.8.0'

@AmandineDB thank you for the provided steps and the workaround. It looks like a new issue. Would you like to crate a separate ticket?

Also, I wonder, if you set the FirebaseAppDelegateProxyEnabled key to NO in your Info.plist so you have to call Messaging.messaging().apnsToken = deviceToken manually? If you don't, then you don't have to set apnsToken yourself (a bit more details here)

Was this page helpful?
0 / 5 - 0 ratings