Skip to content

Commit

Permalink
Merge pull request #1348 from OneSignal/fix_swift_lint
Browse files Browse the repository at this point in the history
Fix swift lint errors
  • Loading branch information
nan-li authored Dec 15, 2023
2 parents 21adb8f + d711d32 commit 4253e09
Show file tree
Hide file tree
Showing 25 changed files with 1,902 additions and 1,507 deletions.
82 changes: 73 additions & 9 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@
3C8E6DF928A6D89E0031E48A /* OSOperationExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C8E6DF828A6D89E0031E48A /* OSOperationExecutor.swift */; };
3C8E6DFF28AB09AE0031E48A /* OSPropertyOperationExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C8E6DFE28AB09AE0031E48A /* OSPropertyOperationExecutor.swift */; };
3C8E6E0128AC0BA10031E48A /* OSIdentityOperationExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C8E6E0028AC0BA10031E48A /* OSIdentityOperationExecutor.swift */; };
3CA6CE0A28E4F19B00CA0585 /* OSUserRequests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA6CE0928E4F19B00CA0585 /* OSUserRequests.swift */; };
3C9AD6BC2B2285FB00BC1540 /* OSUserExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6BB2B2285FB00BC1540 /* OSUserExecutor.swift */; };
3C9AD6BF2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6BE2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift */; };
3C9AD6C12B22886600BC1540 /* OSRequestUpdateSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6C02B22886600BC1540 /* OSRequestUpdateSubscription.swift */; };
3C9AD6C32B22887700BC1540 /* OSRequestCreateUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6C22B22887700BC1540 /* OSRequestCreateUser.swift */; };
3C9AD6C52B228A7300BC1540 /* OSRequestDeleteSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6C42B228A7300BC1540 /* OSRequestDeleteSubscription.swift */; };
3C9AD6C72B228A9800BC1540 /* OSRequestTransferSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6C62B228A9800BC1540 /* OSRequestTransferSubscription.swift */; };
3C9AD6C92B228AB200BC1540 /* OSRequestCreateSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6C82B228AB200BC1540 /* OSRequestCreateSubscription.swift */; };
3C9AD6CB2B228B5200BC1540 /* OSRequestIdentifyUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6CA2B228B5200BC1540 /* OSRequestIdentifyUser.swift */; };
3C9AD6CD2B228B6300BC1540 /* OSRequestFetchUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6CC2B228B6300BC1540 /* OSRequestFetchUser.swift */; };
3C9AD6CF2B228B7800BC1540 /* OSRequestAddAliases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6CE2B228B7800BC1540 /* OSRequestAddAliases.swift */; };
3C9AD6D12B228B9200BC1540 /* OSRequestRemoveAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6D02B228B9200BC1540 /* OSRequestRemoveAlias.swift */; };
3C9AD6D32B228BB000BC1540 /* OSRequestUpdateProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C9AD6D22B228BB000BC1540 /* OSRequestUpdateProperties.swift */; };
3CA6CE0A28E4F19B00CA0585 /* OSUserRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA6CE0928E4F19B00CA0585 /* OSUserRequest.swift */; };
3CC9A6342AFA1FDE008F68FD /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3CC9A6332AFA1FDD008F68FD /* PrivacyInfo.xcprivacy */; };
3CC9A6362AFA26E7008F68FD /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3CC9A6352AFA26E7008F68FD /* PrivacyInfo.xcprivacy */; };
3CCF44BE299B17290021964D /* OneSignalWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3CCF44BC299B17290021964D /* OneSignalWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -749,7 +761,19 @@
3C8E6DF828A6D89E0031E48A /* OSOperationExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSOperationExecutor.swift; sourceTree = "<group>"; };
3C8E6DFE28AB09AE0031E48A /* OSPropertyOperationExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSPropertyOperationExecutor.swift; sourceTree = "<group>"; };
3C8E6E0028AC0BA10031E48A /* OSIdentityOperationExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIdentityOperationExecutor.swift; sourceTree = "<group>"; };
3CA6CE0928E4F19B00CA0585 /* OSUserRequests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSUserRequests.swift; sourceTree = "<group>"; };
3C9AD6BB2B2285FB00BC1540 /* OSUserExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSUserExecutor.swift; sourceTree = "<group>"; };
3C9AD6BE2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestFetchIdentityBySubscription.swift; sourceTree = "<group>"; };
3C9AD6C02B22886600BC1540 /* OSRequestUpdateSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestUpdateSubscription.swift; sourceTree = "<group>"; };
3C9AD6C22B22887700BC1540 /* OSRequestCreateUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestCreateUser.swift; sourceTree = "<group>"; };
3C9AD6C42B228A7300BC1540 /* OSRequestDeleteSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestDeleteSubscription.swift; sourceTree = "<group>"; };
3C9AD6C62B228A9800BC1540 /* OSRequestTransferSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestTransferSubscription.swift; sourceTree = "<group>"; };
3C9AD6C82B228AB200BC1540 /* OSRequestCreateSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestCreateSubscription.swift; sourceTree = "<group>"; };
3C9AD6CA2B228B5200BC1540 /* OSRequestIdentifyUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestIdentifyUser.swift; sourceTree = "<group>"; };
3C9AD6CC2B228B6300BC1540 /* OSRequestFetchUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestFetchUser.swift; sourceTree = "<group>"; };
3C9AD6CE2B228B7800BC1540 /* OSRequestAddAliases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestAddAliases.swift; sourceTree = "<group>"; };
3C9AD6D02B228B9200BC1540 /* OSRequestRemoveAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestRemoveAlias.swift; sourceTree = "<group>"; };
3C9AD6D22B228BB000BC1540 /* OSRequestUpdateProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestUpdateProperties.swift; sourceTree = "<group>"; };
3CA6CE0928E4F19B00CA0585 /* OSUserRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSUserRequest.swift; sourceTree = "<group>"; };
3CC9A6332AFA1FDD008F68FD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3CC9A6352AFA26E7008F68FD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3CCF44BC299B17290021964D /* OneSignalWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalWrapper.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1371,6 +1395,36 @@
path = Source;
sourceTree = "<group>";
};
3C9AD6BA2B2284AB00BC1540 /* Executors */ = {
isa = PBXGroup;
children = (
3C8E6E0028AC0BA10031E48A /* OSIdentityOperationExecutor.swift */,
3C8E6DFE28AB09AE0031E48A /* OSPropertyOperationExecutor.swift */,
3CE795FA28DBDCE700736BD4 /* OSSubscriptionOperationExecutor.swift */,
3C9AD6BB2B2285FB00BC1540 /* OSUserExecutor.swift */,
);
path = Executors;
sourceTree = "<group>";
};
3C9AD6BD2B22877600BC1540 /* Requests */ = {
isa = PBXGroup;
children = (
3CA6CE0928E4F19B00CA0585 /* OSUserRequest.swift */,
3C9AD6C22B22887700BC1540 /* OSRequestCreateUser.swift */,
3C9AD6BE2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift */,
3C9AD6CA2B228B5200BC1540 /* OSRequestIdentifyUser.swift */,
3C9AD6CC2B228B6300BC1540 /* OSRequestFetchUser.swift */,
3C9AD6CE2B228B7800BC1540 /* OSRequestAddAliases.swift */,
3C9AD6D02B228B9200BC1540 /* OSRequestRemoveAlias.swift */,
3C9AD6D22B228BB000BC1540 /* OSRequestUpdateProperties.swift */,
3C9AD6C82B228AB200BC1540 /* OSRequestCreateSubscription.swift */,
3C9AD6C62B228A9800BC1540 /* OSRequestTransferSubscription.swift */,
3C9AD6C02B22886600BC1540 /* OSRequestUpdateSubscription.swift */,
3C9AD6C42B228A7300BC1540 /* OSRequestDeleteSubscription.swift */,
);
path = Requests;
sourceTree = "<group>";
};
3E2400391D4FFC31008BDE70 /* OneSignalFramework */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1584,6 +1638,7 @@
DE69E19C282ED8060090BB3D /* OneSignalUser */ = {
isa = PBXGroup;
children = (
DE69E19D282ED8060090BB3D /* OneSignalUser.h */,
DE69E1A8282ED8360090BB3D /* Source */,
DE69E19E282ED8060090BB3D /* OneSignalUser.docc */,
);
Expand All @@ -1593,20 +1648,17 @@
DE69E1A8282ED8360090BB3D /* Source */ = {
isa = PBXGroup;
children = (
DE69E19D282ED8060090BB3D /* OneSignalUser.h */,
3C9AD6BA2B2284AB00BC1540 /* Executors */,
3C9AD6BD2B22877600BC1540 /* Requests */,
DE69E1A9282ED8790090BB3D /* UnitTestApp-Bridging-Header.h */,
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */,
DE69E1AA282ED8790090BB3D /* OneSignalUserManagerImpl.swift */,
DE69E1A9282ED8790090BB3D /* UnitTestApp-Bridging-Header.h */,
3C2C7DC7288F3C020020F9AE /* OSSubscriptionModel.swift */,
3CE92279289FA88B001B1062 /* OSIdentityModelStoreListener.swift */,
3CF8629D28A183F900776CA4 /* OSIdentityModel.swift */,
3CF862A128A197D200776CA4 /* OSPropertiesModelStoreListener.swift */,
3CF8629F28A1964F00776CA4 /* OSPropertiesModel.swift */,
3C8E6DFE28AB09AE0031E48A /* OSPropertyOperationExecutor.swift */,
3C8E6E0028AC0BA10031E48A /* OSIdentityOperationExecutor.swift */,
3CE795F828DB99B500736BD4 /* OSSubscriptionModelStoreListener.swift */,
3CE795FA28DBDCE700736BD4 /* OSSubscriptionOperationExecutor.swift */,
3CA6CE0928E4F19B00CA0585 /* OSUserRequests.swift */,
3C5117162B15C31E00563465 /* OSUserState.swift */,
);
path = Source;
Expand Down Expand Up @@ -2930,18 +2982,30 @@
files = (
3CE795F928DB99B500736BD4 /* OSSubscriptionModelStoreListener.swift in Sources */,
DE69E1AC282ED87A0090BB3D /* OneSignalUserManagerImpl.swift in Sources */,
3C9AD6CF2B228B7800BC1540 /* OSRequestAddAliases.swift in Sources */,
3C9AD6D32B228BB000BC1540 /* OSRequestUpdateProperties.swift in Sources */,
3C9AD6CD2B228B6300BC1540 /* OSRequestFetchUser.swift in Sources */,
3CF862A028A1964F00776CA4 /* OSPropertiesModel.swift in Sources */,
3C8E6E0128AC0BA10031E48A /* OSIdentityOperationExecutor.swift in Sources */,
3CF862A228A197D200776CA4 /* OSPropertiesModelStoreListener.swift in Sources */,
3C9AD6C12B22886600BC1540 /* OSRequestUpdateSubscription.swift in Sources */,
3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */,
3C8E6DFF28AB09AE0031E48A /* OSPropertyOperationExecutor.swift in Sources */,
3C9AD6CB2B228B5200BC1540 /* OSRequestIdentifyUser.swift in Sources */,
3C9AD6BC2B2285FB00BC1540 /* OSUserExecutor.swift in Sources */,
3C9AD6C32B22887700BC1540 /* OSRequestCreateUser.swift in Sources */,
3C9AD6D12B228B9200BC1540 /* OSRequestRemoveAlias.swift in Sources */,
3C9AD6C92B228AB200BC1540 /* OSRequestCreateSubscription.swift in Sources */,
3C9AD6C52B228A7300BC1540 /* OSRequestDeleteSubscription.swift in Sources */,
3C9AD6C72B228A9800BC1540 /* OSRequestTransferSubscription.swift in Sources */,
3C2C7DC8288F3C020020F9AE /* OSSubscriptionModel.swift in Sources */,
3CF8629E28A183F900776CA4 /* OSIdentityModel.swift in Sources */,
3CE795FB28DBDCE700736BD4 /* OSSubscriptionOperationExecutor.swift in Sources */,
3C5117172B15C31E00563465 /* OSUserState.swift in Sources */,
3C9AD6BF2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift in Sources */,
3CE9227A289FA88B001B1062 /* OSIdentityModelStoreListener.swift in Sources */,
DE69E19F282ED8060090BB3D /* OneSignalUser.docc in Sources */,
3CA6CE0A28E4F19B00CA0585 /* OSUserRequests.swift in Sources */,
3CA6CE0A28E4F19B00CA0585 /* OSUserRequest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public class OSOperationRepo: NSObject {
OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSOperationRepo not flushing queue due to being paused")
return
}

guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: nil) else {
return
}
if (inBackground) {

if inBackground {
OSBackgroundTaskManager.beginBackgroundTask(OPERATION_REPO_BACKGROUND_TASK)
}

Expand Down Expand Up @@ -148,8 +148,8 @@ public class OSOperationRepo: NSObject {
for executor in executors {
executor.processDeltaQueue(inBackground: inBackground)
}
if (inBackground) {

if inBackground {
OSBackgroundTaskManager.endBackgroundTask(OPERATION_REPO_BACKGROUND_TASK)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OSIdentityOperationExecutor: executeAddAliasesRequest making request: \(request)")

let backgroundTaskIdentifier = IDENTITY_EXECUTOR_BACKGROUND_TASK + UUID().uuidString
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.beginBackgroundTask(backgroundTaskIdentifier)
}

OneSignalClient.shared().execute(request) { _ in
// No hydration from response
// On success, remove request from cache
self.addRequestQueue.removeAll(where: { $0 == request})
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue)
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
} onFailure: { error in
Expand All @@ -198,7 +198,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
// Logout if the user in the SDK is the same
guard OneSignalUserManagerImpl.sharedInstance.isCurrentUser(request.identityModel)
else {
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
return
Expand All @@ -212,7 +212,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue)
}
}
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
}
Expand All @@ -230,21 +230,21 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OSIdentityOperationExecutor: executeRemoveAliasRequest making request: \(request)")

let backgroundTaskIdentifier = IDENTITY_EXECUTOR_BACKGROUND_TASK + UUID().uuidString
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.beginBackgroundTask(backgroundTaskIdentifier)
}

OneSignalClient.shared().execute(request) { _ in
// There is nothing to hydrate
// On success, remove request from cache
self.removeRequestQueue.removeAll(where: { $0 == request})
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_REMOVE_REQUEST_QUEUE_KEY, withValue: self.removeRequestQueue)
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
} onFailure: { error in
OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor remove alias request failed with error: \(error.debugDescription)")

if let nsError = error as? NSError {
let responseType = OSNetworkingUtils.getResponseStatusType(nsError.code)
if responseType != .retryable {
Expand All @@ -254,7 +254,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_REMOVE_REQUEST_QUEUE_KEY, withValue: self.removeRequestQueue)
}
}
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
return
}
request.sentToClient = true

let backgroundTaskIdentifier = PROPERTIES_EXECUTOR_BACKGROUND_TASK + UUID().uuidString
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.beginBackgroundTask(backgroundTaskIdentifier)
}

OneSignalClient.shared().execute(request) { _ in
// On success, remove request from cache, and we do need to hydrate
// TODO: We need to hydrate after all ? What why ?
self.updateRequestQueue.removeAll(where: { $0 == request})
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_PROPERTIES_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue)
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
} onFailure: { error in
Expand All @@ -157,7 +157,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
// Logout if the user in the SDK is the same
guard OneSignalUserManagerImpl.sharedInstance.isCurrentUser(request.identityModel)
else {
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
return
Expand All @@ -171,7 +171,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_PROPERTIES_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue)
}
}
if (inBackground) {
if inBackground {
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
}
}
Expand All @@ -189,7 +189,7 @@ extension OSPropertyOperationExecutor {
modelToUpdate: propertiesModel,
identityModel: identityModel)

if (sendImmediately) {
if sendImmediately {
// Bypass the request queues
OneSignalClient.shared().execute(request) { _ in
if let onSuccess = onSuccess {
Expand Down
Loading

0 comments on commit 4253e09

Please sign in to comment.