diff --git a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj index 2b3289e0a..8a5844150 100644 --- a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj +++ b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj @@ -152,6 +152,8 @@ 3CC063E62B6D7F96002BB07F /* OneSignalUserMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC063E52B6D7F96002BB07F /* OneSignalUserMocks.swift */; }; 3CC063EE2B6D7FE8002BB07F /* OneSignalUserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC063ED2B6D7FE8002BB07F /* OneSignalUserTests.swift */; }; 3CC063EF2B6D7FE8002BB07F /* OneSignalUser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE69E19B282ED8060090BB3D /* OneSignalUser.framework */; }; + 3CC47E072EB2D31400C4E4DB /* OneSignalVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 3CC47E052EB2D31400C4E4DB /* OneSignalVersion.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3CC47E082EB2D31400C4E4DB /* OneSignalVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CC47E062EB2D31400C4E4DB /* OneSignalVersion.m */; }; 3CC890352C5BF9A7002CB4CC /* UserConcurrencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC890342C5BF9A7002CB4CC /* UserConcurrencyTests.swift */; }; 3CC9A6342AFA1FDE008F68FD /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3CC9A6332AFA1FDD008F68FD /* PrivacyInfo.xcprivacy */; }; 3CC9A6362AFA26E7008F68FD /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3CC9A6352AFA26E7008F68FD /* PrivacyInfo.xcprivacy */; }; @@ -1315,6 +1317,8 @@ 3CC063E52B6D7F96002BB07F /* OneSignalUserMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneSignalUserMocks.swift; sourceTree = ""; }; 3CC063EB2B6D7FE8002BB07F /* OneSignalUserTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OneSignalUserTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3CC063ED2B6D7FE8002BB07F /* OneSignalUserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneSignalUserTests.swift; sourceTree = ""; }; + 3CC47E052EB2D31400C4E4DB /* OneSignalVersion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalVersion.h; sourceTree = ""; }; + 3CC47E062EB2D31400C4E4DB /* OneSignalVersion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalVersion.m; sourceTree = ""; }; 3CC890342C5BF9A7002CB4CC /* UserConcurrencyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConcurrencyTests.swift; sourceTree = ""; }; 3CC9A6332AFA1FDD008F68FD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 3CC9A6352AFA26E7008F68FD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; @@ -2652,6 +2656,8 @@ DEBA2A252C20E9AA00E234DB /* OSBundleUtils.m */, 3C55013E2E09CF0100E77DF7 /* OSCopyOnWriteSet.h */, 3C55013F2E09CF0100E77DF7 /* OSCopyOnWriteSet.m */, + 3CC47E052EB2D31400C4E4DB /* OneSignalVersion.h */, + 3CC47E062EB2D31400C4E4DB /* OneSignalVersion.m */, ); path = Source; sourceTree = ""; @@ -3173,6 +3179,7 @@ DE7D183D27027F13002D3A5D /* NSURL+OneSignal.h in Headers */, DEBA2A282C24D0F400E234DB /* OSBundleUtils.h in Headers */, DEF784792914667A00A1F3A5 /* NSDateFormatter+OneSignal.h in Headers */, + 3CC47E072EB2D31400C4E4DB /* OneSignalVersion.h in Headers */, DE7D17EB27026B95002D3A5D /* OneSignalCore.h in Headers */, DE7D182A270271A9002D3A5D /* OneSignalCommonDefines.h in Headers */, 3CE8CC522911AE90000DB0D3 /* OSNetworkingUtils.h in Headers */, @@ -4462,6 +4469,7 @@ 3CCF44BF299B17290021964D /* OneSignalWrapper.m in Sources */, DEF78492291479B200A1F3A5 /* OneSignalSelectorHelpers.m in Sources */, DE7D182B27027376002D3A5D /* OSNotification.m in Sources */, + 3CC47E082EB2D31400C4E4DB /* OneSignalVersion.m in Sources */, DE7D187A27037A26002D3A5D /* OneSignalCoreHelper.m in Sources */, 3CE8CC4F2911ADD1000DB0D3 /* OSDeviceUtils.m in Sources */, DE7D1864270374EE002D3A5D /* OneSignalClient.m in Sources */, diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalRequest.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalRequest.m index ca70f8b62..13cfbf952 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalRequest.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalRequest.m @@ -29,6 +29,7 @@ #import "OneSignalCommonDefines.h" #import "OneSignalLog.h" #import "OneSignalWrapper.h" +#import "OneSignalVersion.h" #define HTTP_HEADER_KEY_OS_VERSION @"SDK-Version" #define HTTP_HEADER_KEY_OS_WRAPPER @"SDK-Wrapper" @@ -70,8 +71,8 @@ -(NSMutableURLRequest *)urlRequest { [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:OS_API_ACCEPT_HEADER forHTTPHeaderField:@"Accept"]; - - NSString *versionString = [NSString stringWithFormat:@"%@%@", HTTP_HEADER_PREFIX_OS_VERSION, ONESIGNAL_VERSION]; + + NSString *versionString = [NSString stringWithFormat:@"%@%@", HTTP_HEADER_PREFIX_OS_VERSION, OneSignalVersion.numeric]; [request setValue:versionString forHTTPHeaderField:HTTP_HEADER_KEY_OS_VERSION]; // Set header field if this is used in a wrapper SDK diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.h index c9ee3aa87..1b48a86e6 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.h +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.h @@ -31,9 +31,7 @@ #define NSString_OneSignal_h @interface NSString (OneSignal) -- (NSString *_Nonnull)one_getVersionForRange:(NSRange)range; - (NSString *_Nonnull)one_substringAfter:(NSString *_Nonnull)needle; -- (NSString *_Nonnull)one_getSemanticVersion; - (NSString *_Nullable)fileExtensionForMimeType; - (NSString *_Nullable)supportedFileExtension; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.m index 79b0d0c12..b8fe1fab4 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/Categories/NSString+OneSignal.m @@ -41,30 +41,6 @@ - (NSString *)one_substringAfter:(NSString *)needle } -- (NSString*)one_getVersionForRange:(NSRange)range { - - unichar myBuffer[2]; - [self getCharacters:myBuffer range:range]; - NSString *ver = [NSString stringWithCharacters:myBuffer length:2]; - if([ver hasPrefix:@"0"]){ - return [ver one_substringAfter:@"0"]; - } - else{ - return ver; - } -} - -- (NSString*)one_getSemanticVersion { - - NSMutableString *tmpstr = [[NSMutableString alloc] initWithCapacity:5]; - - for ( int i = 0; i <=4; i+=2 ){ - [tmpstr appendString:[self one_getVersionForRange:NSMakeRange(i, 2)]]; - if (i != 4)[tmpstr appendString:@"."]; - } - - return (NSString*)tmpstr; -} - (NSString *)supportedFileExtension { NSArray *components = [self componentsSeparatedByString:@"."]; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h index 8ed318877..fc0feea6c 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h @@ -46,8 +46,6 @@ // "*" in comment line ending comment means the string value has not been changed // App -#define ONESIGNAL_VERSION @"050215" - #define OSUD_APP_ID @"GT_APP_ID" // * OSUD_APP_ID #define OSUD_REGISTERED_WITH_APPLE @"GT_REGISTERED_WITH_APPLE" // * OSUD_REGISTERED_WITH_APPLE #define OSUD_APP_PROVIDES_NOTIFICATION_SETTINGS @"OS_APP_PROVIDES_NOTIFICATION_SETTINGS" // * OSUD_APP_PROVIDES_NOTIFICATION_SETTINGS diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.h index f3922e961..05700ca25 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.h +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.h @@ -59,6 +59,7 @@ #import #import #import +#import // TODO: Testing: Should this class be defined in this file? @interface OneSignalCoreImpl : NSObject diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.m index 469bf5f91..39272bc1e 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.m @@ -55,7 +55,7 @@ + (void)migrateCachedSdkVersion { } + (void)saveCurrentSDKVersion { - int currentVersion = [ONESIGNAL_VERSION intValue]; + int currentVersion = [OneSignalVersion.numeric intValue]; [OneSignalUserDefaults.initShared saveIntegerForKey:OSUD_CACHED_SDK_VERSION_FOR_CORE withValue:currentVersion]; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.h new file mode 100644 index 000000000..d78c4dbf8 --- /dev/null +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.h @@ -0,0 +1,51 @@ +/** + * Modified MIT License + * + * Copyright 2025 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in connection + * with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Provides access to OneSignal SDK version information. + * Exposes version strings in different formats for use in both Objective-C and Swift. + */ +@interface OneSignalVersion : NSObject + +/** + * Returns the semantic version string (e.g., "5.2.15" or "5.2.3-beta-01") + */ ++ (NSString *)semantic; + +/** + * Returns the numeric version string with zero-padded components (e.g., "050215" or "050203-beta-01") + * Each numeric component is padded to 2 digits. Pre-release suffixes are preserved. + */ ++ (NSString *)numeric; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.m new file mode 100644 index 000000000..b3c5daff1 --- /dev/null +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.m @@ -0,0 +1,48 @@ +/** + * Modified MIT License + * + * Copyright 2025 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in connection + * with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "OneSignalVersion.h" + +/** + * The SDK version - these values are updated by the automation when releasing + * SEMANTIC: "5.2.15" or "5.2.3-beta-01" + * NUMERIC: "050215" or "050203-beta-01" (zero-padded with optional suffix) + */ +static NSString * const ONESIGNAL_VERSION_SEMANTIC = @"5.2.15"; +static NSString * const ONESIGNAL_VERSION_NUMERIC = @"050215"; + +@implementation OneSignalVersion + ++ (NSString *)semantic { + return ONESIGNAL_VERSION_SEMANTIC; +} + ++ (NSString *)numeric { + return ONESIGNAL_VERSION_NUMERIC; +} + +@end diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m index 001dc8569..8aeb616ec 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m @@ -90,7 +90,7 @@ + (void)migrateToOSInAppMessageInternal { } + (void)saveCurrentSDKVersion { - int currentVersion = [ONESIGNAL_VERSION intValue]; + int currentVersion = [OneSignalVersion.numeric intValue]; [OneSignalUserDefaults.initShared saveIntegerForKey:OSUD_CACHED_SDK_VERSION_FOR_IAM withValue:currentVersion]; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m index f246242d3..13ce2a52f 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m +++ b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m @@ -84,7 +84,7 @@ + (void)migrateToVersion_02_14_00_AndGreater { } } + (void)saveCurrentSDKVersion { - let currentVersion = [ONESIGNAL_VERSION intValue]; + let currentVersion = [OneSignalVersion.numeric intValue]; [OneSignalUserDefaults.initShared saveIntegerForKey:OSUD_CACHED_SDK_VERSION_FOR_OUTCOMES withValue:currentVersion]; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift index 6e4799cfb..c5251dfd5 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift @@ -219,7 +219,7 @@ class OSSubscriptionModel: OSModel { } } - var sdk = ONESIGNAL_VERSION { + var sdk = OneSignalVersion.numeric() { didSet { guard sdk != oldValue else { return @@ -324,7 +324,7 @@ class OSSubscriptionModel: OSModel { self.notificationTypes = coder.decodeInteger(forKey: "notificationTypes") self.testType = coder.decodeObject(forKey: "testType") as? Int self.deviceOs = coder.decodeObject(forKey: "deviceOs") as? String ?? UIDevice.current.systemVersion - self.sdk = coder.decodeObject(forKey: "sdk") as? String ?? ONESIGNAL_VERSION + self.sdk = coder.decodeObject(forKey: "sdk") as? String ?? OneSignalVersion.numeric() self.deviceModel = coder.decodeObject(forKey: "deviceModel") as? String self.appVersion = coder.decodeObject(forKey: "appVersion") as? String self.netType = coder.decodeObject(forKey: "netType") as? Int @@ -425,7 +425,7 @@ extension OSSubscriptionModel { func update() { updateTestType() deviceOs = UIDevice.current.systemVersion - sdk = ONESIGNAL_VERSION + sdk = OneSignalVersion.numeric() deviceModel = OSDeviceUtils.getDeviceVariant() appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String netType = OSNetworkingUtils.getNetType() as? Int diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index 10e7157ce..ad65bf2ca 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -133,22 +133,6 @@ + (OneSignalReceiveReceiptsController*)receiveReceiptsController { return _receiveReceiptsController; } -+ (NSString*)sdkVersionRaw { - return ONESIGNAL_VERSION; -} - -// TODO: Is this method used by wrappers? It is not used by this SDK. Can we remove? -+ (NSString*)sdkSemanticVersion { - // examples: - // ONESIGNAL_VERSION = @"020402" returns 2.4.2 - // ONESIGNAL_VERSION = @"001000" returns 0.10.0 - // so that's 6 digits, where the first two are the major version - // the second two are the minor version and that last two, the patch. - // c.f. http://semver.org/ - - return [ONESIGNAL_VERSION one_getSemanticVersion]; -} - //TODO: This is related to unit tests and will change with um tests + (void)clearStatics { [OneSignalConfigManager setAppId:nil]; diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h b/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h index fd5f70c55..1a466d00a 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h +++ b/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h @@ -62,9 +62,6 @@ typedef void (^OSFailureBlock)(NSError* error); // ======= OneSignal Class Interface ========= @interface OneSignal : NSObject -+ (NSString* _Nonnull)sdkVersionRaw; -+ (NSString* _Nonnull)sdkSemanticVersion; - #pragma mark User + (id)User NS_REFINED_FOR_SWIFT; + (void)login:(NSString * _Nonnull)externalId;