make fcm receiver ignore messages when all accounts are disabled
This commit is contained in:
parent
ec54a483f8
commit
383b32c80d
|
@ -34,7 +34,7 @@ public class EventReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasEnabledAccounts(Context context) {
|
||||
public static boolean hasEnabledAccounts(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTING_ENABLED_ACCOUNTS,true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package eu.siacs.conversations.services;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
|
||||
public class PushMessageReceiver extends FirebaseMessagingService {
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage message) {
|
||||
if (!EventReceiver.hasEnabledAccounts(this)) {
|
||||
Log.d(Config.LOGTAG,"PushMessageReceiver ignored message because no accounts are enabled");
|
||||
return;
|
||||
}
|
||||
Map<String, String> data = message.getData();
|
||||
Intent intent = new Intent(this, XmppConnectionService.class);
|
||||
intent.setAction(XmppConnectionService.ACTION_FCM_MESSAGE_RECEIVED);
|
||||
|
|
Loading…
Reference in a new issue