Improve push notification service initialization (#21553)

This commit is contained in:
Parvesh Monu 2024-11-05 19:10:15 +05:30 committed by GitHub
parent cf72bcbe42
commit e43a328c6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -870,7 +870,11 @@ public class PushNotificationHelper {
public void start() {
Log.e(LOG_TAG, "Starting Foreground Service");
Intent serviceIntent = new Intent(context, ForegroundService.class);
context.startService(serviceIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent);
} else {
context.startService(serviceIntent);
}
this.registerBroadcastReceiver();
}