I have a KMP module using a native bridge in Objective-C/Swift for FCM. Android works fine, but on iOS the FirebaseBridge methods are not called from iosMain. It seems FirebasePushNotifierImpl either doesn’t initialize properly, or FirebaseBridge.initializeFirebase() never runs.
Relevant files:
1) Kotlin (iosMain) — FirebasePushNotifierImpl.kt
internal class FirebasePushNotifierImpl : PushNotifier {
private val scope =
CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
init {
scope.launch {
FirebaseBridge.initializeFirebase() // expected to call iOS code
}
}
// getToken, deleteToken, subscribe, etc.
}
2) cinterop .def
language = Objective-C
package = firebasebridge
headers = FirebaseBridgeObjC.h
compilerOpts = -I${projectDir}/../../iosApp/iosApp
3) Swift implementation
@objc public class FirebaseBridge: NSObject {
@objc public static func initializeFirebase() {
DispatchQueue.main.async {
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}
UNUserNotificationCenter.current().delegate =
UIApplication.shared.delegate as? UNUserNotificationCenterDelegate
UIApplication.shared.registerForRemoteNotifications()
}
}
// getToken, deleteToken, subscribe, unsubscribe...
}
4) Objective-C header
@interface FirebaseBridge : NSObject
+ (void)initializeFirebase;
+ (void)getToken:(FBTokenCallback)completion;
+ (void)deleteToken:(FBVoidCallback)completion;
+ (void)subscribeToTopic:(NSString*)topic;
+ (void)unsubscribeFromTopic:(NSString*)topic;
@end
Expected behavior:FirebasePushNotifierImpl initializes and FirebaseBridge.initializeFirebase() executes (I should see NSLog output, and FCM registers device token).
Actual behavior:
No logs from FirebaseBridge, device token not registered. Looks like Kotlin → Objective-C bridge is not called. Build succeeds, no compile errors.