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

Add Firebase in iOS Custom Keyboard Extension

Open khatri6168 opened this issue 1 year ago • 1 comments

Description

Hello Team,

I'm working on Custom Keyboard Extension Project for iOS now. Can I integrate and use Realtime Database in customer Keybord.

But I it's not working in Keybord Extension. could you please check the issue.

Thank.

Reproducing the issue

I just added FirebaseApp.configure() to my KeyboardController Class like this.

if (FirebaseApp.app() == nil) { FirebaseApp.configure() }

Screenshot 2024-05-18 at 12 25 30 PM

but in log showing the message

10.26.0 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add FirebaseApp.configure() to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)(or the@main` struct's initializer in SwiftUI). Read more: https://goo.gl/ctyzm8.

Screenshot 2024-05-18 at 12 26 42 PM

So can you please let me know how can I add FirebaseApp.configure() and access the Realtime Database in my Custom Keyboard Extension app.

I have also add then "GoogleService-Info.plist into this target as well."

Thank you!

Firebase SDK Version

10.26.0

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

Database

Targeted Platforms

iOS

Relevant Log Output

10.26.0 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add `FirebaseApp.configure()` to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's initializer in SwiftUI). Read more: https://goo.gl/ctyzm8.

If using Swift Package Manager, the project's Package.resolved

No response

If using CocoaPods, the project's Podfile.lock

No response

khatri6168 avatar May 18 '24 07:05 khatri6168

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar May 18 '24 07:05 google-oss-bot

Hi @khatri6168, I tried but I can't reproduce the issue. I'm wondering if you're trying to run the main app instead of the extension? If so, I'm wondering if you've added the FirebaseApp.configure() in your AppDelegate? You may also provide the detailed steps to repro or sample app reproducing the issue.

rizafran avatar May 21 '24 13:05 rizafran

Hello @rizafran yes I have add FirebaseApp.configure() in Custom Keyboard Extension main file and in the main project AppDelegate

in the main project when I call it's working and access the Realtime Database but when I open Keybord Extension so in this class showing firebase error this and not access the Realtime Database

10.26.0 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add FirebaseApp.configure() to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)(or the@main` struct's initializer in SwiftUI). Read more: https://goo.gl/ctyzm8.

@rizafran can you please check in Custom Keyboard Extension can I use this firebase and access the Realtime Database.

khatri6168 avatar May 22 '24 12:05 khatri6168

@rizafran also when I check this in simulator the it’s working but when I check in device so not working this

khatri6168 avatar May 22 '24 16:05 khatri6168

Hello @rizafran any update?

khatri6168 avatar Jun 06 '24 08:06 khatri6168

Hi @khatri6168, keyboard extension works in other products (see this test app for sample). For Realtime Database, I've consulted with an engineer if keyboard extension can work, and I'll let you know once I got an update. For the meantime, could you provide a sample app that reproduces the issue since your error is related to the initialization of Firebase app?

rizafran avatar Jun 10 '24 11:06 rizafran

Hey @khatri6168. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jun 17 '24 01:06 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@khatri6168 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Jun 24 '24 01:06 google-oss-bot

Hi @rizafran I'm running into the same error when I open try to open the custom keyboard extension.

Main App:

class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    print("Auteur application is starting up. ApplicationDelegate didFinishLaunchingWithOptions.")
    FirebaseApp.configure()
    return true
  }
}

@main
struct auteurApp: App {
    // register app delegate for Firebase setup
    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
    
    // Initialize the Core Data stack
    let persistentContainer = CoreDataStack.shared.persistentContainer
    
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.managedObjectContext, persistentContainer.viewContext)
        }
    }
}

And then I also have this in the custom keyboard extension:

// Configure Firebase
if FirebaseApp.app() == nil {
     FirebaseApp.configure()
     print("Firebase configured in KeyboardViewController")
     } else {
          print("Firebase already configured in KeyboardViewController")
     }

auteur-dreams avatar Jul 15 '24 21:07 auteur-dreams