mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Background service works
This commit is contained in:
parent
bf53babf53
commit
752cdb04a5
@ -52,9 +52,7 @@ public class NotificationsChannel implements MethodChannel.MethodCallHandler {
|
|||||||
|
|
||||||
private boolean needPreConfiguration() {
|
private boolean needPreConfiguration() {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||||
if (!context.getSystemService(PowerManager.class).isIgnoringBatteryOptimizations(context.getPackageName())) {
|
return !context.getSystemService(PowerManager.class).isIgnoringBatteryOptimizations(context.getPackageName());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -20,6 +21,8 @@ import org.communiquons.comunic.MainActivity;
|
|||||||
import org.communiquons.comunic.R;
|
import org.communiquons.comunic.R;
|
||||||
|
|
||||||
public class NotificationsService extends Service {
|
public class NotificationsService extends Service {
|
||||||
|
private static final String TAG = NotificationsService.class.getSimpleName();
|
||||||
|
|
||||||
public static final String CHANNEL_ID = "IndependentPushServiceChannel";
|
public static final String CHANNEL_ID = "IndependentPushServiceChannel";
|
||||||
private static final String INDEPENDENT_PUSH_NOTIFICATIONS_SERVICE = "independent-push-notifications-service";
|
private static final String INDEPENDENT_PUSH_NOTIFICATIONS_SERVICE = "independent-push-notifications-service";
|
||||||
private static final String WS_URL_PREF_KEY = "ws_url";
|
private static final String WS_URL_PREF_KEY = "ws_url";
|
||||||
@ -97,6 +100,12 @@ public class NotificationsService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
Log.v(TAG, "Destroying service");
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private void initService() {
|
private void initService() {
|
||||||
String url = getSharedPreferences(INDEPENDENT_PUSH_NOTIFICATIONS_SERVICE, MODE_PRIVATE)
|
String url = getSharedPreferences(INDEPENDENT_PUSH_NOTIFICATIONS_SERVICE, MODE_PRIVATE)
|
||||||
.getString(WS_URL_PREF_KEY, null);
|
.getString(WS_URL_PREF_KEY, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user