I\'m receiving that error from Android Studio\'s Android Monitor. This error appears when I send a push notification through GCM, in a real device, and the app has not been
This is because your app is optimized for battery usage to disable that and receive notification even when your app isn't running in background
Add this permission to manifest
While first launch of your app request user for permission to ignore this app for battery optimization
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
}