Firebase services stops when on the background in React Native

Hi guys, I have a problem using the react-native-firebase SDKs from Invertase. I was using the firebase realtime database for my realtime fetching of data, but the firebase stops when you are not on the app (Background). The firebase will start running again when you go back to the app (Foreground). Is there anyone encountered this issue? I have no idea what's wrong, on the Android side, it is working fine even on the background but on the iOS side, it stops and continue when you are on the foreground of the app.

This seems like standard operational procedure for an iOS app. Shortly after the user moves your app to the background, iOS suspends its process [1]. At that point no code is running within the app. iOS apps are expected to work within this constraint, and iOS provides numerous facilities for that.

What do you want your app to do while it’s in the background?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Unless there’s a specific reason to keep it running, for example, it’s playing music.

What I want to do to our app while it’s in the background is to fetch data and show notification if there is new data.

You should do this server side. That is, run code on the server that detects the state that should generate a notification and, when that state occurs, sends a push notification. The system will display the push notification without needing your app to run in the background.

The benefit of this approach is that it moves the energy consumption from the battery-powered client devices to a mains-powered server.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

the FCM doesn't work even the token is correct on testing / sending notification. Do you know the how to solve it?

No.

If you’re looking for help with the Apple side of this then you should start a new thread with the APNS tag. However, you might have more luck escalating this via the support channel for the third-party service you’re using.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Firebase services stops when on the background in React Native
 
 
Q