react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] No such module Firebase

Open CamilMiller opened this issue 10 months ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

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

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

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

  • [x] 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

CamilMiller avatar Jun 03 '25 02:06 CamilMiller

Hi there, try clean and rebuild. Also can I please see your pods file?

MichaelVerdon avatar Jun 03 '25 12:06 MichaelVerdon

Hi there, this issue is going stale so I will be closing this. Please feel free to reopen if the issue persists.

MichaelVerdon avatar Jun 24 '25 10:06 MichaelVerdon