voximplant / react-native-foreground-service

React native module to start foreground service on android
MIT License
159 stars 91 forks source link

how to run the actual code in the foreground service? #31

Open yaodaibao opened 4 years ago

yaodaibao commented 4 years ago

Can't find a way to create foreground service, i just created a notification,is someone now how to create it

acarkaan commented 4 years ago

there is no description ....

prayaslashkari commented 3 years ago

@acarkaan @yaodaibao any information on this? is there any other library that we can use or any native implementation?

acarkaan commented 3 years ago

ı think that when u use foreground fore-service on an app ur tasks will complate on background mode too. so u can add your code to the app normally and everything is ok.

prayaslashkari commented 3 years ago

@acarkaan I tried that but isn't working.

I mean I started the foreground service and executed my code right after that. It wasnt working. Any workaround?

AxelHgt commented 3 years ago

Hi, to make it work you need to add the proper config in the AndroidManifest file: ex: <service android:name="com.voximplant.foregroundservice.VIForegroundService" android:foregroundServiceType="location" android:exported="false"> </service> Once i added the "foregroundServiceType" key i was able to run the code in background. (In my case it's location update)

However i haven't tested it over a long period of time

shuklaharshit commented 10 months ago

can you share the complete react-native code implementation??