Add Firebase in iOS Custom Keyboard Extension
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() }
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.
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
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
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.
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.
@rizafran also when I check this in simulator the it’s working but when I check in device so not working this
Hello @rizafran any update?
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?
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!
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.
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")
}