Giter VIP home page Giter VIP logo

Comments (5)

gpitfield avatar gpitfield commented on August 15, 2024

I see this problem also, when integrating Firebase DynamicLinks, as of version 2.4. As far as I can tell, it renders the integration unusable in any app that wants to use DynamicLinks. The fix above does appear to work, although I haven't verified whether there are other side effects.

from analytics-ios-integration-firebase.

lawicko avatar lawicko commented on August 15, 2024

@gpitfield I have discovered some side effects of my fix, so for you and others who want to use it, please note that the dynamic links will not work if starting the app from the cold state. This is because the fix delays the Firebase setup (namely the moment when [FIRApp configure] is called). So when starting from cold, returning true from ...didFinishLaunchingWithOptions the ...application: UIApplication, continue userActivity: NSUserActivity, restorationHandler... will be called, but at this time the Firebase SDK is not configured properly, so DynamicLinks.dynamicLinks().handleUniversalLink(url) will return false and your callback will never be called.

I have patched this for myself by posting a notification from line 22 of SEGFirebaseIntegration but this is more a hack than anything else. The proper fix should be to actually run the integration setup code on the main queue for the integrations that need this.

from analytics-ios-integration-firebase.

bull-xu avatar bull-xu commented on August 15, 2024

I also use the swizzling for fixing this issue:

Call FirebaseApp.exchange() before the SegmentAnalytics(apiKey: apiKey, factories: factories) then the FirebaseApp.configure() will be called in the main thread.

extension FirebaseApp {
	class func exchange() {
		let origin = #selector(configure as () -> Void)
		let with = #selector(myConfigure)
		exchangeMethod(origin, with: with)
	}

	@objc
	class func myConfigure() {
		DispatchQueue.main.async {
			myConfigure()
		}
	}
  
  class func exchangeMethod(_ originalSelector: Selector, with overriddenSelector: Selector) {
    guard
      let originalMethod = class_getClassMethod(self, originalSelector),
      let overriddenMethod = class_getClassMethod(self, overriddenSelector) else {
        return
    }
    method_exchangeImplementations(originalMethod, overriddenMethod)
  }
}

from analytics-ios-integration-firebase.

bull-xu avatar bull-xu commented on August 15, 2024

Another thing to be considered: Because the Segment will have a remote call to fetch the configuration setting options before the FirebaseApp.configure() got called. Before that, the FirebaseApp.app() is always nil, if you want to use any feature of it, you need to wait for the remote call return and configure being called. There is a notification we can use to detect this: FIRAppReadyToConfigureSDKNotification.

from analytics-ios-integration-firebase.

taraspasichnyk avatar taraspasichnyk commented on August 15, 2024

@briemcnally, maybe you could add some input on this issue?

from analytics-ios-integration-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.