Doze mode is for saving your battery. You should put your app in white list For deactivate doze mode.
Source : https://developer.android.com/training/monitoring-device-state/doze-standby
Support for other use cases
Almost all apps should be able to support Doze by managing network connectivity, alarms, jobs, and syncs properly, and by using FCM
high-priority messages. For a narrow set of use cases, this might not
be sufficient. For such cases, the system provides a configurable
whitelist of apps that are partially exempt from Doze and App Standby
optimizations.
An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. However, other restrictions
still apply to the whitelisted app, just as they do to other apps. For
example, the whitelisted app’s jobs and syncs are deferred (on API
level 23 and below), and its regular AlarmManager alarms do not fire.
An app can check whether it is currently on the exemption whitelist by
calling isIgnoringBatteryOptimizations().
And Here how to insert your app to white list :
1. Step --> Add this permission in your xml file.
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
2.Step İgnore battery optimizations
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);
}
}