Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase support #891

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions PushSharp.Google/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@

namespace PushSharp.Google
{
public class GcmNotificationException : NotificationException
public class FcmNotificationException : NotificationException
{
public GcmNotificationException (GcmNotification notification, string msg) : base (msg, notification)
public FcmNotificationException (FcmNotification notification, string msg) : base (msg, notification)
{
Notification = notification;
}

public GcmNotificationException (GcmNotification notification, string msg, string description) : base (msg, notification)
public FcmNotificationException (FcmNotification notification, string msg, string description) : base (msg, notification)
{
Notification = notification;
Description = description;
}

public new GcmNotification Notification { get; private set; }
public new FcmNotification Notification { get; private set; }
public string Description { get; private set; }
}

public class GcmMulticastResultException : Exception
public class FcmMulticastResultException : Exception
{
public GcmMulticastResultException () : base ("One or more Registration Id's failed in the multicast notification")
public FcmMulticastResultException () : base ("One or more Registration Id's failed in the multicast notification")
{
Succeeded = new List<GcmNotification> ();
Failed = new Dictionary<GcmNotification, Exception> ();
Succeeded = new List<FcmNotification> ();
Failed = new Dictionary<FcmNotification, Exception> ();
}

public List<GcmNotification> Succeeded { get;set; }
public List<FcmNotification> Succeeded { get;set; }

public Dictionary<GcmNotification, Exception> Failed { get;set; }
public Dictionary<FcmNotification, Exception> Failed { get;set; }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace PushSharp.Google
{
public class GcmConfiguration
public class FcmConfiguration
{
private const string GCM_SEND_URL = "https://gcm-http.googleapis.com/gcm/send";
private const string FCM_SEND_URL = "https://fcm.googleapis.com/fcm/send";

public GcmConfiguration (string senderAuthToken)
public FcmConfiguration (string senderAuthToken)
{
this.SenderAuthToken = senderAuthToken;
this.GcmUrl = GCM_SEND_URL;
this.FcmUrl = FCM_SEND_URL;

this.ValidateServerCertificate = false;
}

public GcmConfiguration (string optionalSenderID, string senderAuthToken, string optionalApplicationIdPackageName)
public FcmConfiguration (string optionalSenderID, string senderAuthToken, string optionalApplicationIdPackageName)
{
this.SenderID = optionalSenderID;
this.SenderAuthToken = senderAuthToken;
this.ApplicationIdPackageName = optionalApplicationIdPackageName;
this.GcmUrl = GCM_SEND_URL;
this.FcmUrl = FCM_SEND_URL;

this.ValidateServerCertificate = false;
}
Expand All @@ -32,11 +32,11 @@ public GcmConfiguration (string optionalSenderID, string senderAuthToken, string

public bool ValidateServerCertificate { get; set; }

public string GcmUrl { get; set; }
public string FcmUrl { get; set; }

public void OverrideUrl (string url)
{
GcmUrl = url;
FcmUrl = url;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;

namespace PushSharp.Google
{
public class GcmMessageResult
public class FcmMessageResult
{
[JsonProperty("message_id", NullValueHandling = NullValueHandling.Ignore)]
public string MessageId { get; set; }
Expand All @@ -15,7 +15,7 @@ public class GcmMessageResult
public string CanonicalRegistrationId { get; set; }

[JsonIgnore]
public GcmResponseStatus ResponseStatus { get; set; }
public FcmResponseStatus ResponseStatus { get; set; }

[JsonProperty("error", NullValueHandling = NullValueHandling.Ignore)]
public string Error
Expand All @@ -24,35 +24,35 @@ public string Error
{
switch (ResponseStatus)
{
case GcmResponseStatus.Ok:
case FcmResponseStatus.Ok:
return null;
case GcmResponseStatus.Unavailable:
case FcmResponseStatus.Unavailable:
return "Unavailable";
case GcmResponseStatus.QuotaExceeded:
case FcmResponseStatus.QuotaExceeded:
return "QuotaExceeded";
case GcmResponseStatus.NotRegistered:
case FcmResponseStatus.NotRegistered:
return "NotRegistered";
case GcmResponseStatus.MissingRegistrationId:
case FcmResponseStatus.MissingRegistrationId:
return "MissingRegistration";
case GcmResponseStatus.MissingCollapseKey:
case FcmResponseStatus.MissingCollapseKey:
return "MissingCollapseKey";
case GcmResponseStatus.MismatchSenderId:
case FcmResponseStatus.MismatchSenderId:
return "MismatchSenderId";
case GcmResponseStatus.MessageTooBig:
case FcmResponseStatus.MessageTooBig:
return "MessageTooBig";
case GcmResponseStatus.InvalidTtl:
case FcmResponseStatus.InvalidTtl:
return "InvalidTtl";
case GcmResponseStatus.InvalidRegistration:
case FcmResponseStatus.InvalidRegistration:
return "InvalidRegistration";
case GcmResponseStatus.InvalidDataKey:
case FcmResponseStatus.InvalidDataKey:
return "InvalidDataKey";
case GcmResponseStatus.InternalServerError:
case FcmResponseStatus.InternalServerError:
return "InternalServerError";
case GcmResponseStatus.DeviceQuotaExceeded:
case FcmResponseStatus.DeviceQuotaExceeded:
return null;
case GcmResponseStatus.CanonicalRegistrationId:
case FcmResponseStatus.CanonicalRegistrationId:
return null;
case GcmResponseStatus.Error:
case FcmResponseStatus.Error:
return "Error";
default:
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
Expand All @@ -8,11 +8,11 @@

namespace PushSharp.Google
{
public class GcmNotification : INotification
public class FcmNotification : INotification
{
public static GcmNotification ForSingleResult (GcmResponse response, int resultIndex)
public static FcmNotification ForSingleResult (FcmResponse response, int resultIndex)
{
var result = new GcmNotification ();
var result = new FcmNotification ();
result.Tag = response.OriginalNotification.Tag;
result.MessageId = response.OriginalNotification.MessageId;

Expand All @@ -31,9 +31,9 @@ public static GcmNotification ForSingleResult (GcmResponse response, int resultI
return result;
}

public static GcmNotification ForSingleRegistrationId (GcmNotification msg, string registrationId)
public static FcmNotification ForSingleRegistrationId (FcmNotification msg, string registrationId)
{
var result = new GcmNotification ();
var result = new FcmNotification ();
result.Tag = msg.Tag;
result.MessageId = msg.MessageId;
result.RegistrationIds.Add (registrationId);
Expand All @@ -49,7 +49,7 @@ public static GcmNotification ForSingleRegistrationId (GcmNotification msg, stri
return result;
}

public GcmNotification ()
public FcmNotification ()
{
RegistrationIds = new List<string> ();
CollapseKey = string.Empty;
Expand Down Expand Up @@ -101,7 +101,7 @@ public bool IsDeviceRegistrationIdValid ()
public JObject Notification { get; set; }

/// <summary>
/// If true, GCM will only be delivered once the device's screen is on
/// If true, FCM will only be delivered once the device's screen is on
/// </summary>
[JsonProperty ("delay_while_idle")]
public bool? DelayWhileIdle { get; set; }
Expand All @@ -121,7 +121,7 @@ public bool IsDeviceRegistrationIdValid ()
/// <summary>
/// A string that maps a single user to multiple registration IDs associated with that user. This allows a 3rd-party server to send a single message to multiple app instances (typically on multiple devices) owned by a single user.
/// </summary>
[Obsolete ("Deprecated on GCM Server API. Use Device Group Messaging to send to multiple devices.")]
[Obsolete ("Deprecated on FCM Server API. Use Device Group Messaging to send to multiple devices.")]
public string NotificationKey { get; set; }

/// <summary>
Expand All @@ -142,7 +142,7 @@ public bool IsDeviceRegistrationIdValid ()
/// </summary>
/// <value>The priority.</value>
[JsonProperty ("priority"), JsonConverter (typeof (Newtonsoft.Json.Converters.StringEnumConverter))]
public GcmNotificationPriority? Priority { get; set; }
public FcmNotificationPriority? Priority { get; set; }

internal string GetJson ()
{
Expand All @@ -163,7 +163,7 @@ public override string ToString ()
}
}

public enum GcmNotificationPriority
public enum FcmNotificationPriority
{
[EnumMember (Value="normal")]
Normal = 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

namespace PushSharp.Google
{
public class GcmResponse
public class FcmResponse
{
public GcmResponse()
public FcmResponse()
{
MulticastId = -1;
NumberOfSuccesses = 0;
NumberOfFailures = 0;
NumberOfCanonicalIds = 0;
OriginalNotification = null;
Results = new List<GcmMessageResult>();
ResponseCode = GcmResponseCode.Ok;
Results = new List<FcmMessageResult>();
ResponseCode = FcmResponseCode.Ok;
}

[JsonProperty("multicast_id")]
Expand All @@ -31,16 +31,16 @@ public GcmResponse()
public long NumberOfCanonicalIds { get; set; }

[JsonIgnore]
public GcmNotification OriginalNotification { get; set; }
public FcmNotification OriginalNotification { get; set; }

[JsonProperty("results")]
public List<GcmMessageResult> Results { get; set; }
public List<FcmMessageResult> Results { get; set; }

[JsonIgnore]
public GcmResponseCode ResponseCode { get; set; }
public FcmResponseCode ResponseCode { get; set; }
}

public enum GcmResponseCode
public enum FcmResponseCode
{
Ok,
Error,
Expand All @@ -50,7 +50,7 @@ public enum GcmResponseCode
InternalServiceError
}

public enum GcmResponseStatus
public enum FcmResponseStatus
{
[EnumMember (Value="Ok")]
Ok,
Expand Down
Loading