title: Notifications are delayed in Android 8.0+
body: <p>I experience delays with pushes for Android O. Notifications are delayed or even aren't shown at all. It happens in both states: foreground and background. But there is no such problem for any other android version. I've provided notification channels for api 26+. Tried to change priority, to disable battery optimisation. But nothing worked.</p>
  
  <p>Now my implementation for urban airship looks like:</p>
  
  <pre><code>public class UrbanAirshipWrapper {
      private static class MyNotificationFactory extends DefaultNotificationFactory {
          public MyNotificationFactory(@NonNull Context context) {
              super(context);
  
              if (Build.VERSION.SDK_INT &gt;= 26) {
                  String channelId = "defaultChannel";
                  NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
                  NotificationChannel channel = new NotificationChannel(channelId, context.getString(R.string.notification_default_channel), NotificationManager.IMPORTANCE_DEFAULT);
  
                  channel.setSound(null, null);
                  if (notificationManager != null) {
                      notificationManager.createNotificationChannel(channel);
                      setNotificationChannel(channelId);
                  }
              }
  
              setSmallIconId(R.drawable.ic_notification);
              setColor(ContextCompat.getColor(context, R.color.notification));
          }
  
          @Override
          public NotificationCompat.Builder extendBuilder(@NonNull NotificationCompat.Builder builder, @NonNull PushMessage message, int notificationId) {
              if (notificationAllowed(message)) {
                  return soundBuilder(builder, message);
              } else {
                  return null; // preventing notification
              }
          }
  
  
          private boolean notificationAllowed(@NonNull PushMessage message) {
              Bundle pushBundle = message.getPushBundle();
              String centerId = pushBundle.getString(CENTER_ID);
              String objectNumber = pushBundle.getString(OBJECT_NUMBER);
              String type = pushBundle.getString(NOTIFICATION_TYPE);
  
              // not allowed arm_error for currently visible area
              if (TYPE_ARM_ERROR.equals(type) || TYPE_DISARM_ERROR.equals(type)) {
                  if (centerId != null &amp;&amp; objectNumber != null &amp;&amp; (centerId + objectNumber).equals(sCurrentCenterPlusObject)) {
                      return false;
                  }
              }
  
              return true; // allowed by default
          }
  
          private NotificationCompat.Builder soundBuilder(@NonNull NotificationCompat.Builder builder, @NonNull PushMessage message) {
              Bundle pushBundle = message.getPushBundle();
              String sound = pushBundle.getString(SOUND);
  
              if (TextUtils.isEmpty(sound)) {
                  if (Build.VERSION.SDK_INT &lt; 26) {
                      builder.setSound(null);
                  } else {
                      RingtoneManager.getRingtone(getContext(), Settings.System.DEFAULT_NOTIFICATION_URI).play();
                  }
              } else {
                  Uri uri = Uri.parse("android.resource://" + getContext().getPackageName() + "/raw/" + sound);
  
                  if (Build.VERSION.SDK_INT &lt; 26) {
                      builder.setSound(uri);
                  } else {
                      RingtoneManager.getRingtone(getContext(), uri).play();
                  }
              }
  
              return builder;
          }
      }
  
      public static String sCurrentCenterPlusObject;
  
      private UrbanAirshipWrapper() { }
  
      @SuppressWarnings("deprecation")
      public static void initialize(Application application, String prodAppKey, String prodAppSecret, String gcmSender) {
          AirshipConfigOptions options = new AirshipConfigOptions.Builder()
              .setInProduction(true)
              .setProductionAppKey(prodAppKey)
              .setProductionAppSecret(prodAppSecret)
              .setGcmSender(gcmSender).build();
  
          UAirship.takeOff(application, options);
          UAirship.shared().getPushManager().setUserNotificationsEnabled(true);
          UAirship.shared().getPushManager().setNotificationFactory(new MyNotificationFactory(application));
      }
  }
  </code></pre>
  
  <p>Notifications were sent via GCM and it's just data messages without any images. But I get the following error when push shows with delay:</p>
  
  <p><code>01-25 21:58:46.336 27657-27910/com.example.app W/EnhancedIntentService: Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed.
  </code></p>
  
  <p>I think that it can be a source of the problem. I've already tried to disable my custom notification factory. Also I disabled receiver and services that relate with notifications. But problem's still there.</p>
  
  <p>Is there any way to fix this?</p>