Skip to content

Commit 2d241bb

Browse files
committed
Make OSResponseStatusType enum to categorize status codes
* Borrow from Android and introduce 5 categories of server responses: - Unauthorized - Missing - Conflict - Retryable
1 parent f2a38f4 commit 2d241bb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OSNetworkingUtils.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@
2929

3030
// NS_ASSUME_NONNULL_BEGIN
3131

32+
typedef NS_ENUM(NSInteger, OSResponseStatusType) {
33+
OSResponseStatusInvalid = 0,
34+
OSResponseStatusRetryable,
35+
OSResponseStatusUnauthorized,
36+
OSResponseStatusMissing,
37+
OSResponseStatusConflict
38+
};
39+
3240
@interface OSNetworkingUtils : NSObject
3341

3442
+ (NSNumber*)getNetType;
43+
+ (OSResponseStatusType)getResponseStatusType:(NSInteger)statusCode;
3544

3645
@end
3746

iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OSNetworkingUtils.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ + (NSNumber *)getNetType {
3838
return @1;
3939
}
4040

41+
+ (OSResponseStatusType)getResponseStatusType:(NSInteger)statusCode {
42+
if (statusCode == 400 || statusCode == 402) {
43+
return OSResponseStatusInvalid;
44+
} else if (statusCode == 401 || statusCode == 403) {
45+
return OSResponseStatusUnauthorized;
46+
} else if (statusCode == 404 || statusCode == 410) {
47+
return OSResponseStatusMissing;
48+
} else if (statusCode == 409) {
49+
return OSResponseStatusConflict;
50+
} else {
51+
return OSResponseStatusRetryable;
52+
}
53+
}
54+
4155
@end

0 commit comments

Comments
 (0)