title: Device Subscription Expired - Fix
body: <p>I am using PushSharp library to send Push Notification to my Xamarin.Android App. Each time while launching the app, I am checking GCM registration and if registration expires, I am sending the device token to server. Sometimes I am getting </p>
  
  <blockquote>
    <p>Device Subscription Expired Exception</p>
  </blockquote>
  
  <p>in log. Due to this exception my device is not receiving notification and sometimes it is getting resolved automatically and I am started receiving notification. I am not sure what is happening. How to fix this issue?</p>
  
  <p>I could handle DeviceSubscriptionExcpetion as below:</p>
  
  <pre><code>gcmBroker.OnNotificationFailed += (notification, aggregateEx) =&gt;
  {
    if (ex is DeviceSubscriptonExpiredException)
    {
      var subExc = ex as DeviceSubscriptonExpiredException;
    }
  }
  </code></pre>
  
  <p>I could delete the expired token from DB, but my confusion is actually device token is not expired. Device is valid but sometimes unable to receive notification due to this exception.</p>
  
  <p>According to <a href="https://stackoverflow.com/questions/18992017/android-gcm-server-error-device-subscription-expired">this</a> thread it happens only when we have multiple registration for the same device. But I am storing device token against unique device ID. I am getting device id as below:</p>
  
  <pre><code>try
              {
                  var telephonyManager = (TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService);
                  if (telephonyManager != null)
                  {
                      deviceId = telephonyManager.DeviceId;
  
                      if (string.IsNullOrEmpty(deviceId))
                      {
                        deviceId = Android.OS.Build.Serial;
                      }
                  }
              }
  </code></pre>
  
  <p>Even though its said that device id is unique, but its changing most of the time. Other way I am guessing to fix this exception is by getting some ID that is always unique in Android device.</p>
  
  <p>Please give some suggestion to fix this issue. </p>