Skip to content

Commit

Permalink
Try and avoid specifying both To and RegistrationIds in GCM
Browse files Browse the repository at this point in the history
This should help with issue #629
  • Loading branch information
Redth committed May 10, 2016
1 parent d8a5bb1 commit 615068f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion PushSharp.Google/GcmNotification.cs
Expand Up @@ -141,7 +141,15 @@ public bool IsDeviceRegistrationIdValid ()

internal string GetJson ()
{
return JsonConvert.SerializeObject (this);
// If 'To' was used instead of RegistrationIds, let's make RegistrationId's null
// so we don't serialize an empty array for this property
// otherwise, google will complain that we specified both instead
if (RegistrationIds != null && RegistrationIds.Count <= 0 && !string.IsNullOrEmpty (To))
RegistrationIds = null;

// Ignore null values
return JsonConvert.SerializeObject (this,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
}

public override string ToString ()
Expand Down

0 comments on commit 615068f

Please sign in to comment.