firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Add Firebase to iOS app extension

Open msavoaia opened this issue 3 years ago • 21 comments

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one of the above categories, reach out to Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 11.7
  • Firebase SDK version: 6.7.1
  • Firebase Component: Core
  • Component version: 6.7.1
  • Installation method: CocoaPods

[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?

  • Create a new app into the firebase
  • Follow the steps to integrate the Firebase into the iOS app extension

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()
    }
}

msavoaia avatar Sep 29 '20 21:09 msavoaia

Can you share the logs from running your extension?

morganchen12 avatar Sep 29 '20 22:09 morganchen12

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.

ryanwilson avatar Sep 30 '20 12:09 ryanwilson

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.

msavoaia avatar Sep 30 '20 14:09 msavoaia

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.

ryanwilson avatar Sep 30 '20 14:09 ryanwilson

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

msavoaia avatar Sep 30 '20 14:09 msavoaia

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

morganchen12 avatar Sep 30 '20 16:09 morganchen12

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

msavoaia avatar Oct 01 '20 14:10 msavoaia

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

paulb777 avatar Oct 01 '20 14:10 paulb777

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

msavoaia avatar Oct 01 '20 18:10 msavoaia

@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

nikans avatar Oct 03 '20 17:10 nikans

@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).

dennisrcs avatar Nov 05 '20 02:11 dennisrcs

@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."

adriennealyzee avatar Feb 24 '21 09:02 adriennealyzee

@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.

OGmetamonkey avatar Jun 30 '21 19:06 OGmetamonkey

When will Firebase start supporting app extensions ?

wshrads avatar Jul 08 '21 18:07 wshrads

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

JMCPH avatar Oct 15 '21 09:10 JMCPH

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

Unfortunately no. Still waiting to hear back from Firebase.

wshrads avatar Oct 15 '21 11:10 wshrads

I think extensions need open access to reach use internet.

deepak013 avatar Mar 11 '22 17:03 deepak013

@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 avatar Mar 14 '22 16:03 charlotteliang

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?

SwiftNativeDeveloper avatar Oct 31 '23 18:10 SwiftNativeDeveloper

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.

paulb777 avatar Oct 31 '23 18:10 paulb777

@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

kroussevrb avatar Feb 09 '24 09:02 kroussevrb