title: Unable to recieve notifications from Firebase. Unregistered registration token
body: <p>I have setup Firebase in an Xamarin.Android application, following this guide:
  <a href="https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-fcm/" rel="nofollow noreferrer">https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-fcm/</a></p>
  
  <p>It seemed to work at first, with receiving notifications without problems. Then I tried to update the code and redeploy to Device and afterwards nothing happened. Since I have been unable to receive any notifications from the Firebase Console.</p>
  
  <p>I have tried</p>
  
  <ul>
  <li>Uninstall application and deploy again</li>
  <li>Download new google-service.json from Firebase Console</li>
  <li>Delete and setup new Firebase Project, and updating google-service.json for this</li>
  </ul>
  
  <p>When the application is newly deployed, and I try to send a notification, nothing happens. After an update and redeploy I get the error "Unregistered registration token" in the console.</p>
  
  <p>Before setting up a new Firebase Project I would get the following error when trying to subscribe to a topic
  "INVALID_PARAMETERS", but this problem has seen to disappear after creating a new project. Now then subscribing to Topic, it appears in the Console after some time. But trying to send notifications to the topic, gives no results.</p>
  
  <p><strong>Edit - Added code</strong></p>
  
  <p>MainActivity.cs</p>
  
  <pre><code>[Activity(Label = "&lt;&lt;App Label&gt;&gt;", MainLauncher = true, Icon = "@drawable/icon")]
  public class MainActivity : Activity
  {
      private TextView msgText;
      private const string Tag = "MainActivity";
      private FirebaseAnalytics _analytics;
  
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
  
          _analytics = FirebaseAnalytics.GetInstance(this);
  
          // Set our view from the "main" layout resource
          SetContentView (Resource.Layout.Main);
          msgText = FindViewById&lt;TextView&gt;(Resource.Id.msgText);
  
          if (Intent.Extras != null)
          {
              foreach (var key in Intent.Extras.KeySet())
              {
                  var value = Intent.Extras.GetString(key);
                  Log.Debug(Tag, "Key: {0} Value: {1}", key, value);
              }
          }
  
          IsPlayServicesAvailable();
  
          var logTokenButton = FindViewById&lt;Button&gt;(Resource.Id.logTokenButton);
          logTokenButton.Click += delegate {
              Log.Debug(Tag, "InstanceID token: " + FirebaseInstanceId.Instance.Token);
          };
  
          var subButton = FindViewById&lt;Button&gt;(Resource.Id.subscribeButton);
          subButton.Click += SubButton_Click;
      }
  
      private void SubButton_Click(object sender, System.EventArgs e)
      {
          FirebaseMessaging.Instance.SubscribeToTopic("A");
          Log.Debug(Tag, "Subscribed to A");
      }
  
      public bool IsPlayServicesAvailable()
      {
          int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);
          if (resultCode != ConnectionResult.Success)
          {
              if (GoogleApiAvailability.Instance.IsUserResolvableError(resultCode))
                  msgText.Text = GoogleApiAvailability.Instance.GetErrorString(resultCode);
              else
              {
                  msgText.Text = "This device is not supported";
                  Finish();
              }
              return false;
          }
          else
          {
              msgText.Text = "Google Play Services is available.";
              return true;
          }
      }
  }
  </code></pre>
  
  <p>StwFirebaseInstanceIdService.cs</p>
  
  <pre><code>[Service]
  [IntentFilter(new []{ "com.google.firebase.INSTANCE_ID_EVENT" })]
  public class StwFirebaseInstanceIdService : FirebaseInstanceIdService
  {
      private const string Tag = "StwFirebaseInstanceIdService";
      public override void OnTokenRefresh()
      {
          var refreshedToken = FirebaseInstanceId.Instance.Token;
          Log.Debug(Tag, "Refreshed Token: " + refreshedToken);
          //SendRegistrationToServer(refreshedToken);
      }
  
      private void SendRegistrationToServer(string token)
      {
  
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="&lt;&lt;Package Name&gt;&gt;" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"&gt;
  &lt;uses-sdk android:minSdkVersion="16" /&gt;
  &lt;application android:label="&lt;&lt;App Label&gt;&gt;"&gt;
      &lt;receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /&gt;
      &lt;receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
              &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
              &lt;category android:name="${applicationId}" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>