Skip to content

Commit d58a51e

Browse files
committed
[nits] Move public protocols out of User Manager file
* OneSignalUserManagerImpl.swift violated the 1000 line file limit of Swiftlint * Options include modifing the rule but let's pull out 2 public protocols. * Additionally add more folders to organize the top-level files: MODELING for models and listeners, PUBLIC for publicly accessed objects and protocols
1 parent 1d7d585 commit d58a51e

12 files changed

+136
-60
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
3C2C7DC8288F3C020020F9AE /* OSSubscriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2C7DC7288F3C020020F9AE /* OSSubscriptionModel.swift */; };
7676
3C2D8A5928B4C4E300BE41F6 /* OSDelta.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2D8A5828B4C4E300BE41F6 /* OSDelta.swift */; };
7777
3C2FF9D02C5FCD760081293B /* OSUserJwtConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2FF9CF2C5FCD760081293B /* OSUserJwtConfig.swift */; };
78+
3C3130E02CA383F800906665 /* OSUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C3130DF2CA383F800906665 /* OSUser.swift */; };
79+
3C3130E32CA3858500906665 /* OSPushSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C3130E22CA3858500906665 /* OSPushSubscription.swift */; };
7880
3C44673E296D099D0039A49E /* OneSignalMobileProvision.m in Sources */ = {isa = PBXBuildFile; fileRef = 912411FD1E73342200E41FD7 /* OneSignalMobileProvision.m */; };
7981
3C44673F296D09CC0039A49E /* OneSignalMobileProvision.h in Headers */ = {isa = PBXBuildFile; fileRef = 912411FC1E73342200E41FD7 /* OneSignalMobileProvision.h */; settings = {ATTRIBUTES = (Public, ); }; };
8082
3C448B9D2936ADFD002F96BC /* OSBackgroundTaskHandlerImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C448B9B2936ADFD002F96BC /* OSBackgroundTaskHandlerImpl.h */; };
@@ -1238,6 +1240,8 @@
12381240
3C2C7DC7288F3C020020F9AE /* OSSubscriptionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSSubscriptionModel.swift; sourceTree = "<group>"; };
12391241
3C2D8A5828B4C4E300BE41F6 /* OSDelta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSDelta.swift; sourceTree = "<group>"; };
12401242
3C2FF9CF2C5FCD760081293B /* OSUserJwtConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSUserJwtConfig.swift; sourceTree = "<group>"; };
1243+
3C3130DF2CA383F800906665 /* OSUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSUser.swift; sourceTree = "<group>"; };
1244+
3C3130E22CA3858500906665 /* OSPushSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSPushSubscription.swift; sourceTree = "<group>"; };
12411245
3C448B9B2936ADFD002F96BC /* OSBackgroundTaskHandlerImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSBackgroundTaskHandlerImpl.h; sourceTree = "<group>"; };
12421246
3C448B9C2936ADFD002F96BC /* OSBackgroundTaskHandlerImpl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSBackgroundTaskHandlerImpl.m; sourceTree = "<group>"; };
12431247
3C448BA12936B474002F96BC /* OSBackgroundTaskManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSBackgroundTaskManager.swift; sourceTree = "<group>"; };
@@ -2101,6 +2105,30 @@
21012105
path = Jwt;
21022106
sourceTree = "<group>";
21032107
};
2108+
3C3130E12CA384BD00906665 /* Modeling */ = {
2109+
isa = PBXGroup;
2110+
children = (
2111+
3CF8629D28A183F900776CA4 /* OSIdentityModel.swift */,
2112+
3CF8629F28A1964F00776CA4 /* OSPropertiesModel.swift */,
2113+
3C2C7DC7288F3C020020F9AE /* OSSubscriptionModel.swift */,
2114+
3CE92279289FA88B001B1062 /* OSIdentityModelStoreListener.swift */,
2115+
3CF862A128A197D200776CA4 /* OSPropertiesModelStoreListener.swift */,
2116+
3CE795F828DB99B500736BD4 /* OSSubscriptionModelStoreListener.swift */,
2117+
);
2118+
path = Modeling;
2119+
sourceTree = "<group>";
2120+
};
2121+
3C3130E52CA385B700906665 /* Public */ = {
2122+
isa = PBXGroup;
2123+
children = (
2124+
3C3130DF2CA383F800906665 /* OSUser.swift */,
2125+
3C3130E22CA3858500906665 /* OSPushSubscription.swift */,
2126+
3C5117162B15C31E00563465 /* OSUserState.swift */,
2127+
DE1DD05F2C87D87B00787071 /* OSJwtInvalidatedEvent.swift */,
2128+
);
2129+
path = Public;
2130+
sourceTree = "<group>";
2131+
};
21042132
3C8544B72C5AEFF700F542A9 /* OneSignalOSCoreMocks */ = {
21052133
isa = PBXGroup;
21062134
children = (
@@ -2493,20 +2521,14 @@
24932521
isa = PBXGroup;
24942522
children = (
24952523
3CEE90A52BFE6A7700B0FB5B /* Support */,
2524+
3C3130E12CA384BD00906665 /* Modeling */,
24962525
3C9AD6BA2B2284AB00BC1540 /* Executors */,
24972526
3C9AD6BD2B22877600BC1540 /* Requests */,
2527+
3C3130E52CA385B700906665 /* Public */,
24982528
DE69E1A9282ED8790090BB3D /* UnitTestApp-Bridging-Header.h */,
2499-
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */,
25002529
DE69E1AA282ED8790090BB3D /* OneSignalUserManagerImpl.swift */,
2530+
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */,
25012531
3C277D7D2BD76E0000857606 /* OSIdentityModelRepo.swift */,
2502-
3C2C7DC7288F3C020020F9AE /* OSSubscriptionModel.swift */,
2503-
3CE92279289FA88B001B1062 /* OSIdentityModelStoreListener.swift */,
2504-
3CF8629D28A183F900776CA4 /* OSIdentityModel.swift */,
2505-
3CF862A128A197D200776CA4 /* OSPropertiesModelStoreListener.swift */,
2506-
3CF8629F28A1964F00776CA4 /* OSPropertiesModel.swift */,
2507-
3CE795F828DB99B500736BD4 /* OSSubscriptionModelStoreListener.swift */,
2508-
3C5117162B15C31E00563465 /* OSUserState.swift */,
2509-
DE1DD05F2C87D87B00787071 /* OSJwtInvalidatedEvent.swift */,
25102532
);
25112533
path = Source;
25122534
sourceTree = "<group>";
@@ -4315,6 +4337,7 @@
43154337
3C277D7E2BD76E0000857606 /* OSIdentityModelRepo.swift in Sources */,
43164338
3CEE90A72BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift in Sources */,
43174339
3C9AD6C12B22886600BC1540 /* OSRequestUpdateSubscription.swift in Sources */,
4340+
3C3130E02CA383F800906665 /* OSUser.swift in Sources */,
43184341
3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */,
43194342
3C8E6DFF28AB09AE0031E48A /* OSPropertyOperationExecutor.swift in Sources */,
43204343
3C9AD6CB2B228B5200BC1540 /* OSRequestIdentifyUser.swift in Sources */,
@@ -4328,6 +4351,7 @@
43284351
3C2C7DC8288F3C020020F9AE /* OSSubscriptionModel.swift in Sources */,
43294352
3CF8629E28A183F900776CA4 /* OSIdentityModel.swift in Sources */,
43304353
3CE795FB28DBDCE700736BD4 /* OSSubscriptionOperationExecutor.swift in Sources */,
4354+
3C3130E32CA3858500906665 /* OSPushSubscription.swift in Sources */,
43314355
3C5117172B15C31E00563465 /* OSUserState.swift in Sources */,
43324356
3C9AD6BF2B22881D00BC1540 /* OSRequestFetchIdentityBySubscription.swift in Sources */,
43334357
3CE9227A289FA88B001B1062 /* OSIdentityModelStoreListener.swift in Sources */,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,57 +44,6 @@ import OneSignalNotifications
4444
func sendPurchases(_ purchases: [[String: AnyObject]])
4545
}
4646

47-
/**
48-
This is the user interface exposed to the public.
49-
*/
50-
@objc public protocol OSUser {
51-
var pushSubscription: OSPushSubscription { get }
52-
var onesignalId: String? { get }
53-
var externalId: String? { get }
54-
/**
55-
Add an observer to the user state, allowing the provider to be notified when the user state has changed.
56-
Important: When using the observer to retrieve the `onesignalId`, check the `externalId` as well to confirm the values are associated with the expected user.
57-
*/
58-
func addObserver(_ observer: OSUserStateObserver)
59-
func removeObserver(_ observer: OSUserStateObserver)
60-
// Aliases
61-
func addAlias(label: String, id: String)
62-
func addAliases(_ aliases: [String: String])
63-
func removeAlias(_ label: String)
64-
func removeAliases(_ labels: [String])
65-
// Tags
66-
func addTag(key: String, value: String)
67-
func addTags(_ tags: [String: String])
68-
func removeTag(_ tag: String)
69-
func removeTags(_ tags: [String])
70-
func getTags() -> [String: String]
71-
// Email
72-
func addEmail(_ email: String)
73-
func removeEmail(_ email: String)
74-
// SMS
75-
func addSms(_ number: String)
76-
func removeSms(_ number: String)
77-
// Language
78-
func setLanguage(_ language: String)
79-
// JWT Token Expire
80-
typealias OSJwtInvalidatedHandler = (_ event: OSJwtInvalidatedEvent) -> Void
81-
func onJwtInvalidated(invalidatedHandler: @escaping OSJwtInvalidatedHandler)
82-
}
83-
84-
/**
85-
This is the push subscription interface exposed to the public.
86-
*/
87-
@objc public protocol OSPushSubscription {
88-
var id: String? { get }
89-
var token: String? { get }
90-
var optedIn: Bool { get }
91-
92-
func optIn()
93-
func optOut()
94-
func addObserver(_ observer: OSPushSubscriptionObserver)
95-
func removeObserver(_ observer: OSPushSubscriptionObserver)
96-
}
97-
9847
@objc
9948
public class OneSignalUserManagerImpl: NSObject, OneSignalUserManager {
10049
@objc public static let sharedInstance = OneSignalUserManagerImpl(jwtConfig: OSUserJwtConfig())
File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Modified MIT License
3+
4+
Copyright 2024 OneSignal
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
1. The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
2. All copies of substantial portions of the Software may only be used in connection
17+
with services provided by OneSignal.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
*/
27+
28+
/**
29+
This is the push subscription interface exposed to the public.
30+
*/
31+
@objc public protocol OSPushSubscription {
32+
var id: String? { get }
33+
var token: String? { get }
34+
var optedIn: Bool { get }
35+
36+
func optIn()
37+
func optOut()
38+
func addObserver(_ observer: OSPushSubscriptionObserver)
39+
func removeObserver(_ observer: OSPushSubscriptionObserver)
40+
}

0 commit comments

Comments
 (0)