title: How to implement the CrossPushNotification plugin in Xamarin Forms?
body: <p>I have implemented the <code>IPushNotificationListener</code>, in my <code>CrossPushNotificationListener</code> class. As suggested in the <a href="https://github.com/rdelrosario/xamarin-plugins/tree/master/PushNotification" rel="nofollow noreferrer">README</a> file.</p>
  
  <pre><code>public class CrossPushNotificationListener : IPushNotificationListener
  {
      void IPushNotificationListener.OnError(string message, DeviceType deviceType)
      {
          Application.Current.MainPage.DisplayAlert("error", message, "ok");
      }
  
      void IPushNotificationListener.OnMessage(JObject values, DeviceType deviceType)
      {
          Application.Current.MainPage.DisplayAlert("message", values.ToString(), "ok");
      }
  
      void IPushNotificationListener.OnRegistered(string token, DeviceType deviceType)
      {
          Application.Current.MainPage.DisplayAlert("token", token, "ok");
      }
  
      void IPushNotificationListener.OnUnregistered(DeviceType deviceType)
      {
          Application.Current.MainPage.DisplayAlert("unregistered", "", "ok");
      }
  
      bool IPushNotificationListener.ShouldShowNotification()
      {
          Application.Current.MainPage.DisplayAlert("should show notification", "", "ok");
          return true;
      }
  }
  </code></pre>
  
  <p>In iOS’s AppDelegate, I then initialize the CrossPushNotification plugin.</p>
  
  <pre><code>public override bool FinishedLaunching(UIApplication app, NSDictionary options)
  {
      global::Xamarin.Forms.Forms.Init ();
  
      CrossPushNotification.Initialize&lt;CrossPushNotificationListener&gt;();
  
      LoadApplication(new Origination.App ());
      return base.FinishedLaunching(app, options);
  }
  </code></pre>
  
  <p>I have also extended the AppDelegate with the appropriate overrides as shown in the <code>PushNotificationApplicationDelegate.txt.pp</code> file:</p>
  
  <pre><code>public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
  {
      if (CrossPushNotification.Current is IPushNotificationHandler)
      {
          ((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);
      }
  }
  
  public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
  {
      if (CrossPushNotification.Current is IPushNotificationHandler)
      {
          ((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken);
      }
  }
  
  
  public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action&lt;UIBackgroundFetchResult&gt; completionHandler)
  {
      if (CrossPushNotification.Current is IPushNotificationHandler)
      {
          ((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
      }
  }
  
  
  public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
  {
      if (CrossPushNotification.Current is IPushNotificationHandler)
      {
          ((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
      }
  }
  </code></pre>
  
  <p>Afterwards, in my shared code, after the user registered/logged in the App and enter it's home screen, I call:</p>
  
  <pre><code>CrossPushNotification.Current.Register();
  </code></pre>
  
  <p>I know this method is being executed, as I get an alert requesting permissions. But none of the methods from the <code>IPushNotificationListener</code> interface implemented in the <code>CrossPushNotificationListener</code> are called.</p>
  
  <p>What am I missing here?</p>
  
  <p>Thank you.</p>