From f4c8e0cf0c3b0d7587980ced99c6c308e554336c Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 7 May 2024 17:57:36 +0800 Subject: [PATCH] fix: start push service when app in background --- .../java/org/telegram/messenger/NotificationsService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java index c4ec95a50d..51fc8aa7a8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java @@ -17,6 +17,7 @@ import android.content.SharedPreferences; import android.os.Build; import android.os.IBinder; +import android.util.Log; import androidx.core.app.NotificationCompat; @@ -43,7 +44,11 @@ public void onCreate() { .setSmallIcon(R.drawable.notification) .setContentText(LocaleController.getString("NekoXPushService", R.string.NekoXPushService)) .build(); - startForeground(9999, notification); + try { + startForeground(9999, notification); + } catch (Throwable e) { + Log.d("TFOSS", "Failed to start push service"); + } } }