Leveraging OkVerify's foreground service
OkVerify's foreground service improves the reliability and stability of verification signals coming from your user's mobile phone. Here's how to use it
Due to the Background Execution Limits introduced in Android 8 as well as restrictions imposed by some device manufacturers its become increasingly difficult to determine accurate and timely verification signals within android applications. In order to ensure reliability of these verification signals, the library comes with an opt-in foreground service that you can leverage to decrease the amount of time it takes to verify an address.
Starting the foreground service
Configure a notification that'll be used to start the service
After successfully starting verification on an address, call the static startForegroundService
method available in the OkVerify class.
At this point a persistent notification will be shown to the user, signalling that the foreground service has indeed started successfully
Stopping the foreground service
Stopping the service is easy, simply make a call to the stopForegroundService
static method that is available on the OkVerify class
Stopping the foreground service does not stop verification of that address, the library will continue to use background services in order to obtain verification signals.
Determining whether the foreground service is running
You can make a call to the static method isForegroundServiceRunning
method on the OkVerify class to determine whether a foreground service is present and running
Be sure to checkout our best practices doc for more information on foreground services
Last updated