Skip to content

Commit 71a4414

Browse files
committed
v4.1.0 Fixing issues with APN
1 parent 8c070a9 commit 71a4414

File tree

3 files changed

+45
-37
lines changed

3 files changed

+45
-37
lines changed

CorePush/Apple/ApnSender.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ public async Task<ApnsResponse> SendAsync(
9898

9999
using var response = await http.SendAsync(message, cancellationToken);
100100

101-
var succeed = response.IsSuccessStatusCode;
101+
var success = response.IsSuccessStatusCode;
102102
var content = await response.Content.ReadAsStringAsync(cancellationToken);
103-
var error = serializer.Deserialize<ApnsError>(content);
104103

105104
return new ApnsResponse
106105
{
107-
IsSuccess = succeed,
108-
Error = error
106+
IsSuccess = success,
107+
Error = success ? null : serializer.Deserialize<ApnsError>(content)
109108
};
110109
}
111110

CorePush/Apple/ApnsResponse.cs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,44 @@ public class ApnsResponse
99

1010
public class ApnsError
1111
{
12-
public ReasonEnum Reason {get; set;}
12+
/// <summary>
13+
/// Use <see cref="ApnsErrorReasons"/> to compare against
14+
/// </summary>
15+
public string Reason {get; set;}
1316
public long? Timestamp {get; set; }
1417
}
1518

1619
/// <summary>
1720
/// https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW15
1821
/// </summary>
19-
public enum ReasonEnum
22+
public static class ApnsErrorReasons
2023
{
21-
BadCollapseId,
22-
BadDeviceToken,
23-
BadExpirationDate,
24-
BadMessageId,
25-
BadPriority,
26-
BadTopic,
27-
DeviceTokenNotForTopic,
28-
DuplicateHeaders,
29-
IdleTimeout,
30-
MissingDeviceToken,
31-
MissingTopic,
32-
PayloadEmpty,
33-
TopicDisallowed,
34-
BadCertificate,
35-
BadCertificateEnvironment,
36-
ExpiredProviderToken,
37-
Forbidden,
38-
InvalidProviderToken,
39-
MissingProviderToken,
40-
BadPath,
41-
MethodNotAllowed,
42-
Unregistered,
43-
PayloadTooLarge,
44-
TooManyProviderTokenUpdates,
45-
TooManyRequests,
46-
InternalServerError,
47-
ServiceUnavailable,
48-
Shutdown,
24+
public const string BadCollapseId = "BadCollapseId";
25+
public const string BadDeviceToken = "BadDeviceToken";
26+
public const string BadExpirationDate = "BadExpirationDate";
27+
public const string BadMessageId = "BadMessageId";
28+
public const string BadPriority = "BadPriority";
29+
public const string BadTopic = "BadTopic";
30+
public const string DeviceTokenNotForTopic = "DeviceTokenNotForTopic";
31+
public const string DuplicateHeaders = "DuplicateHeaders";
32+
public const string IdleTimeout = "IdleTimeout";
33+
public const string MissingDeviceToken = "MissingDeviceToken";
34+
public const string MissingTopic = "MissingTopic";
35+
public const string PayloadEmpty = "PayloadEmpty";
36+
public const string TopicDisallowed = "TopicDisallowed";
37+
public const string BadCertificate = "BadCertificate";
38+
public const string BadCertificateEnvironment = "BadCertificateEnvironment";
39+
public const string ExpiredProviderToken = "ExpiredProviderToken";
40+
public const string Forbidden = "Forbidden";
41+
public const string InvalidProviderToken = "InvalidProviderToken";
42+
public const string MissingProviderToken = "MissingProviderToken";
43+
public const string BadPath = "BadPath";
44+
public const string MethodNotAllowed = "MethodNotAllowed";
45+
public const string Unregistered = "Unregistered";
46+
public const string PayloadTooLarge = "PayloadTooLarge";
47+
public const string TooManyProviderTokenUpdates = "TooManyProviderTokenUpdates";
48+
public const string TooManyRequests = "TooManyRequests";
49+
public const string InternalServerError = "InternalServerError";
50+
public const string ServiceUnavailable = "ServiceUnavailable";
51+
public const string Shutdown = "Shutdown";
4952
}

CorePush/CorePush.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<Summary>Server Side library for sending ✅Web, ✅Android and ✅iOS Push Notifications</Summary>
1111
<Authors>andrei-m-code</Authors>
1212

13-
<AssemblyVersion>4.0.2</AssemblyVersion>
14-
<FileVersion>4.0.2</FileVersion>
15-
<Version>4.0.2</Version>
13+
<AssemblyVersion>4.1.0</AssemblyVersion>
14+
<FileVersion>4.1.0</FileVersion>
15+
<Version>4.1.0</Version>
1616

1717
<PackageProjectUrl>https://github.com/andrei-m-code/CorePush</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/andrei-m-code/CorePush</RepositoryUrl>
@@ -25,6 +25,12 @@
2525
<PackageTags>push-notifications android-push-notifications ios-push-notifications web-push web-push-notifications apn fcm firebase</PackageTags>
2626

2727
<PackageReleaseNotes>
28+
v4.1.0
29+
- Bugfixing issues with APNS response handling
30+
31+
v4.0.2
32+
- Issues with Firebase configuration
33+
2834
v4.0.1
2935
- Use .NET 7.0 as a target framework
3036
- Use System.Text.Json as a default serializer

0 commit comments

Comments
 (0)