title: App crashes with java.lang.IllegalStateException: Not allowed to start service Intent while receiving notification in background
body: <p>Xamarin forms android application targeting api level 26 crashes with <code>java.lang.IllegalStateException: Not allowed to start service Intent</code>
  when receiving notification in background. </p>
  
  <p>From <a href="https://stackoverflow.com/questions/46445265/android-8-0-java-lang-illegalstateexception-not-allowed-to-start-service-inten">Notification in oreo</a>, what i understood is only during the app whitelisted duration only the app can make services. How to properly handle this situvation, i call and update my databases when i receive notification, how can i properly manage this.</p>
  
  <p>One answer shows </p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.N_MR1) {
          context.startForegroundService(new Intent(context, ServedService.class));
      } else {
          context.startService(new Intent(context, ServedService.class));
      }
  </code></pre>
  
  <p>But how can i implement this in a xamarin forms application for properly receiving push notifications.</p>