Is there any way to run a foreground service in react native?

6.4k views Asked by At

I've been doing a few searches on google trying to find a way to run foreground services in react native but I haven't found much about it.

Is anyone aware of how to accomplish this? This is what I mean by foreground service: https://developer.android.com/guide/components/services.html#Foreground

2

There are 2 answers

1
harapalb On

Edit: for some reason the link isn't working anymore.This is the good link as pointed out by DAN.

Here's a package react-native-foreground-service i found, while I was dealing with the same issue.

0
SeattleStephens On

I have an example React Native Foreground Service app here. In this example, I'm doing a Bluetooth scan every 10 seconds and attempting to run a Foreground Service so that the scans will continue even if the app isn't in the foreground.

You can remove the call in index.js that does the BLE scan and you'll have a simple RN Foreground Service example.