Skip to content

[🐛] No such module Firebase #8554

@CamilMiller

Description

@CamilMiller

Is there an existing issue for this?

  • I have searched the existing issues.

Please confirm you are aware of the 'Other' platform limitations.

  • I confirm that issue is not relating to a known platform limitation.

Please confirm, this issue is NOT for Android or iOS?

  • I confirm that this issue is not for Android and not for iOS.

Please describe your issue here.

is not working

import UIKit
import Firebase
import FirebaseCore
import FirebaseMessaging
import React_RCTAppDelegate
import ReactAppDependencyProvider
import UserNotifications

@main
class AppDelegate: RCTAppDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  ) -> Bool {
    // Configure Firebase first
    FirebaseApp.configure()
    
    // Initialize Firebase Messaging
    Messaging.messaging().delegate = self
    
    // Set up UserNotifications
    UNUserNotificationCenter.current().delegate = self
    
    // Initialize React Native
    self.moduleName = "flixsy_rn_app"
    
    // Call super after Firebase setup
    let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)
    
    // Request notification permissions
    let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
    UNUserNotificationCenter.current().requestAuthorization(
      options: authOptions,
      completionHandler: { granted, error in
        if let error = error {
          print("Error requesting notification authorization: \(error.localizedDescription)")
        }
        if granted {
          print("Notification permission granted.")
        } else {
          print("Notification permission denied.")
        }
      }
    )
    application.registerForRemoteNotifications()
    
    return result
  }
  
  override func sourceURL(for bridge: RCTBridge!) -> URL! {
    #if DEBUG
      return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
    #else
      return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
    #endif
  }

  // MARK: - Push Notifications Registration
  
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print("Registered for remote notifications with device token: \(deviceToken.map { String(format: "%02.2hhx", $0) }.joined())")
    // Pass device token to Firebase Messaging
    Messaging.messaging().apnsToken = deviceToken
  }
  
  func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    print("Failed to register for remote notifications: \(error.localizedDescription)")
  }
}

// MARK: - MessagingDelegate
extension AppDelegate: MessagingDelegate {
  func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
    // Handle FCM token refresh
  }
}
Image

Additional context and comments

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions