title: Processing notifications in Xamarin Forms Android
body: <p>I'm using the library <a href="https://github.com/aritchie/notifications" rel="nofollow noreferrer">https://github.com/aritchie/notifications</a> and I can create and schedule notifications properly.</p>
  
  <p>I wish to process them in Android so that depending on the notification - it will navigate to a particular page when the user taps on it.</p>
  
  <p>I've found that the below event is fired when I tap on a notification (in my Android Project)</p>
  
  <pre><code> protected override void OnNewIntent(Intent intent)
      {
  
      }
  </code></pre>
  
  <p>However, I can't find any info in the intent from my notification in order to build up navigation to a particular page. </p>
  
  <p>Any advice would be appreciated.</p>
  
  <p>Cheers!</p>
  
  <p>Edit #1 (Adding additional code for a related issue):</p>
  
  <p>If I fire off a notification, and close the app before the notification is received - I receive an error saying the app has crashed. If I receive the notification and close the app - I can load the app from the notification OK.</p>
  
  <p>I have a dependency service which hits the following methods.</p>
  
  <pre><code>public void Remind(DateTime dateTime, string msgtype, string usermedid)
      {
          DateTime now = DateTime.Now;
          var diffinseconds = (dateTime - now).TotalSeconds;
          Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmBroadcastReceiver));
          alarmIntent.PutExtra("notificationtype", msgtype);
          alarmIntent.PutExtra("id", id);
  
  
          PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
          AlarmManager alarmManager = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);
  
          //TODO: For demo set after 5 seconds.
          alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + diffinseconds * 1000, pendingIntent);
  
      }
  
      [BroadcastReceiver(Enabled = true)]
      [IntentFilter(new string[]{"android.intent.action.BOOT_COMPLETED"}, Priority = (int) IntentFilterPriority.LowPriority)]
      public class AlarmBroadcastReceiver : BroadcastReceiver
      {
          public override void OnReceive(Context context, Intent intent)
          {
              string notificationtype = intent.GetStringExtra("notificationtype");
  
              PowerManager.WakeLock sWakeLock;
              var pm = PowerManager.FromContext(context);
              sWakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "GCM Broadcast Reciever Tag");
              sWakeLock.Acquire();
  
              intent = new Intent(Forms.Context, typeof(MainActivity));
              intent.PutExtra("notificationtype", notificationtype);
              intent.AddFlags(ActivityFlags.IncludeStoppedPackages);
  
  
  
              // Instantiate the builder and set notification elements, including pending intent:
              NotificationCompat.Builder builder = new NotificationCompat.Builder(Forms.Context)
                  .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate)
                  .SetAutoCancel(true)
                  .SetContentIntent(PendingIntent.GetActivity(Forms.Context, 0, intent, 0)).SetContentTitle("Sample Notification")
                  .SetContentText("Hello World! This is my first action notification!")
                  .SetTicker("New Notification")
  
                  .SetSmallIcon(Resource.Drawable.icon);
  
  
              // Build the notification:
              Android.App.Notification notification = builder.Build();
  
              notification.Flags = NotificationFlags.AutoCancel;
  
              // Get the notification manager:
              //NotificationManager notificationManager = Forms.Context.GetSystemService(Context.NotificationService) as NotificationManager;
              var manager = NotificationManagerCompat.From(context);
  
              // Publish the notification:
              const int notificationId = 0;
              manager.Notify(notificationId, notification);
  
              sWakeLock.Release();
  
  
  
          }
      }
  </code></pre>
  
  <p>How do I keep my Broadcast Receiver alive when the app is closed?</p>