firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.67k stars 1.49k forks source link

Add Firebase to iOS app extension #6605

Open msavoaia opened 4 years ago

msavoaia commented 4 years ago

Step 0: Are you in the right place?

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

The iOS application extension is not connecting with Firebase servers.

Screen Shot 2020-09-30 at 12 48 16 AM

Steps to reproduce:

What happened? How can we make the problem occur?

If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.

Relevant Code:

class PacketTunnelProvider: NEPacketTunnelProvider {

    override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
        FirebaseApp.configure()
    }
}
morganchen12 commented 4 years ago

Can you share the logs from running your extension?

ryanwilson commented 4 years ago

One thing to note as well: that step requires that Analytics is included in target. If Analytics is excluded, feel free to skip this step. I was under the impression we had a note there specifying this, but I can see what happened to it.

msavoaia commented 4 years ago

One thing to note as well: that step requires that Analytics is included in target. If Analytics is excluded, feel free to skip this step. I was under the impression we had a note there specifying this, but I can see what happened to it.

Analytics is included in target:

  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'

Can you share the logs from running your extension?

There aren't logs related to Firebase at all.

ryanwilson commented 4 years ago

If you set a breakpoint on FirebaseApp.configure() does it get called at all? There should definitely be logs from Firebase if that's called, and even if Analytics is included in the target.

msavoaia commented 4 years ago

If you set a breakpoint on FirebaseApp.configure() does it get called at all? There should definitely be logs from Firebase if that's called, and even if Analytics is included in the target.

It gets called.

<Notice>: [Firebase/Crashlytics] Version 4.1.1
<Notice>: 6.25.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60501000 started
<Notice>: 6.25.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
<Notice>: 6.25.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
<Notice>: 6.25.0 - [Firebase/Analytics][I-ACS031025] 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
<Notice>: 6.25.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
morganchen12 commented 4 years ago

This may be related to Analytics' (Firedata's) bundle identifier per project restrictions.

msavoaia commented 4 years ago

I have two bundle identifiers and two separate applications in Firebase. One for the container application and another one for the extension.

paulb777 commented 4 years ago

See #2896. FirebaseAnalytics is not currently supported for extensions.

msavoaia commented 4 years ago

@paulb777 How about Crashlytics? Can be used without Analytics?

nikans commented 4 years ago

@madalinsavoaiavrazo works for me. On Firebase I've created a separate app with custom keyboard extension bundle id, and initiated firebase in viewDidLoad of the principle kb class

dennisrcs commented 4 years ago

@nikans I am trying to do exactly that (keyboard extension access firebase). I am able to write/read to/from Firebase when running my app in the simulator but it doesn't work when I run it on my device.

Did you have to set any special permission or entitlement? I also tried to access a shared container using App Groups and it doesn't seem to work either (works fine in the simulator).

adriennealyzee commented 3 years ago

@nikans Initiating firebase in the viewDidLoad works for the app extension, but now getting an error "The file “remote_config.json” couldn’t be opened because there is no such file."

OGmetamonkey commented 3 years ago

@madalinsavoaiavrazo works for me. On Firebase I've created a separate app with custom keyboard extension bundle id, and initiated firebase in viewDidLoad of the principle kb class

What is the principal kb class? I trued to run

    override func viewDidLoad() {
        super.viewDidLoad()
        FirebaseApp.configure()
    }

in my extension's CredentialProviderViewController class and it doesn't run.

I try to just include FirebaseApp.configure() outside of a viewDidLoad() and get

Consecutive declarations on a line must be separated by ';'

I can run it inside a function (override func prepareCredentialList) and it seems to work, but my extension won't return a user object, when the main app is definitely authenticated.

wshrads commented 3 years ago

When will Firebase start supporting app extensions ?

JMCPH commented 3 years ago

@wshrads did you ever get it to work for extensions?

wshrads commented 3 years ago

@wshrads did you ever get it to work for extensions?

Unfortunately no. Still waiting to hear back from Firebase.

deepak013 commented 2 years ago

I think extensions need open access to reach use internet.

charlotteliang commented 2 years ago

@msavoaia Crashlytics should just work. Let us know if your issue is resolved since analytics is not supported.

@wshrads if it's a different extension than the one above, can you file a separate issue mentioning which extension you are using and if you can share your sample of using Firebase would be very helpful. thank you!

SwiftNativeDeveloper commented 1 year ago

Anything for 2023? Almost 2024 and iOS App are using extensions now more than ever. Can you solve this by adding an app group as the storage mechanism for the extensions to SAVE and have the main app target upload?

paulb777 commented 1 year ago

We're not likely to have comprehensive app extension support anytime soon. That said, many of the Firebase products work with many types of app extensions. If you'd like support for a specific use case, please open another issue.

kroussevrb commented 9 months ago

@msavoaia Crashlytics should just work. Let us know if your issue is resolved since analytics is not supported.

@wshrads if it's a different extension than the one above, can you file a separate issue mentioning which extension you are using and if you can share your sample of using Firebase would be very helpful. thank you!

@charlotteliang What do you mean "should just work" - same Firebase app and plist file? Two Firebase apps and the same plist? Two plists? cc @paulb777