A minimal use example?
agat opened this issue · 4 comments
Can you provide a minimal working code with example? Thanks.
Hello, @agat !
We have not created an example project yet, however you can take a look at the example usage in our react-native demo for audio and video calls. We use foreground service module there to keep the access to camera and microphone while the application in the background for android 8+.
Commit with foreground service integration: voximplant/react-native-demo@6107c2c
Usage example:
- start service: https://github.com/voximplant/react-native-demo/blob/6107c2c1d1fc8019f3a605b42622fcc1ac67457d/src/screens/CallScreen.js#L225-L243
- stop service: https://github.com/voximplant/react-native-demo/blob/6107c2c1d1fc8019f3a605b42622fcc1ac67457d/src/screens/CallScreen.js#L212-L216
In our demo application we use foreground service only for android 8+, however foreground service module works on earlier android versions, minSdkVersion in set to 16.
The nuance is that to run foreground service on Android 8+ it is required to create notification channel, so we have provided appropriate Api for that (createNotificationChannel). If the application is running on Android < 8, you need just to use startService and stopService methods.
Please let me know if you have any questions or face any issues.
Best regards,
Yulia Grigorieva
Hello!
We have created a simple demo project with 2 buttons: start/stop foreground service:
https://github.com/voximplant/react-native-foreground-service-demo
Best regards,
Yulia Grigorieva
@YuliaGrigorieva , Where do you add the background running code?
+1