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

[šŸ“š] How to inject isHeadless prop into AppDelegate.swift file

Open hossein-rashno opened this issue 7 months ago • 10 comments

The messaging documentation explains how to inject isHeadless prop into the AppDelegate.m file. But as you know, new RN releases are using AppDelegate.swift files. I recently upgraded my RN version to 0.79.5, but now I have no clue how to inject isHeadless into my swift file.

Could someone please update the documentation with a swift example?

hossein-rashno avatar Jul 09 '25 08:07 hossein-rashno

I’m using React Native 0.79.5 with Firebase 22.4.0, and I ran into the same issue with the transition from AppDelegate.m to AppDelegate.swift.

To inject the isHeadless prop, I followed this approach in my AppDelegate.swift:

func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
  // šŸ”§ Firebase initialization
  FirebaseApp.configure()

  // ——— React Native bootstrapping ———
  let delegate = ReactNativeDelegate()
  let factory = RCTReactNativeFactory(delegate: delegate)
  delegate.dependencyProvider = RCTAppDependencyProvider()

  reactNativeDelegate = delegate
  reactNativeFactory = factory

  window = UIWindow(frame: UIScreen.main.bounds)
  factory.startReactNative(
    withModuleName: "<YOUR_PACKAGE_NAME>",
    in: window,
    initialProperties: RNFBMessagingModule.addCustomProps(
      toUserProps: nil,
      withLaunchOptions: launchOptions
    ),
    launchOptions: launchOptions
  )

  return true
}

tomisykora avatar Jul 10 '25 14:07 tomisykora

@tomisykora May I know if isHeadless prop working properly with react native 0.79 new architecture?

aliceni81 avatar Jul 18 '25 09:07 aliceni81

As tested, isHeadless prop does not working properly with new architecture for iOS quit state.

aliceni81 avatar Jul 22 '25 02:07 aliceni81

It looks like I have the same issue after upgrading RN to 0.79. isHeadless is true when I receive a push notification and then open the app from the app icon. The isHeadless check returns null, and the app opens with a white screen. After closing and reopening the app, everything works as expected.

mrkrand avatar Aug 18 '25 17:08 mrkrand

Hello šŸ‘‹, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Sep 15 '25 17:09 github-actions[bot]

It looks like I have the same issue after upgrading RN to 0.79. isHeadless is true when I receive a push notification and then open the app from the app icon. The isHeadless check returns null, and the app opens with a white screen. After closing and reopening the app, everything works as expected.

Actually it's due to the new architecture. If you opt-in old architecture, isHeadless works.

aliceni81 avatar Sep 16 '25 07:09 aliceni81

To solve the problem programmatically, please refer to https://github.com/invertase/react-native-firebase/issues/8248#issuecomment-2681039536.

aliceni81 avatar Sep 16 '25 07:09 aliceni81

Hello šŸ‘‹, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Oct 14 '25 09:10 github-actions[bot]

The isHeadless prop stuff (here and in related issue #8248) is not resolved well in documentation or practice yet, I believe

mikehardy avatar Oct 29 '25 10:10 mikehardy

Hello šŸ‘‹, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Nov 26 '25 11:11 github-actions[bot]