Skip to content
Closed

x #1598

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -1315,6 +1317,8 @@
3CC063E52B6D7F96002BB07F /* OneSignalUserMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneSignalUserMocks.swift; sourceTree = "<group>"; };
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 = "<group>"; };
3CC47E052EB2D31400C4E4DB /* OneSignalVersion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalVersion.h; sourceTree = "<group>"; };
3CC47E062EB2D31400C4E4DB /* OneSignalVersion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalVersion.m; sourceTree = "<group>"; };
3CC890342C5BF9A7002CB4CC /* UserConcurrencyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConcurrencyTests.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>"; };
Expand Down Expand Up @@ -2652,6 +2656,8 @@
DEBA2A252C20E9AA00E234DB /* OSBundleUtils.m */,
3C55013E2E09CF0100E77DF7 /* OSCopyOnWriteSet.h */,
3C55013F2E09CF0100E77DF7 /* OSCopyOnWriteSet.m */,
3CC47E052EB2D31400C4E4DB /* OneSignalVersion.h */,
3CC47E062EB2D31400C4E4DB /* OneSignalVersion.m */,
);
path = Source;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NSString *> *components = [self componentsSeparatedByString:@"."];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#import <OneSignalCore/OSBundleUtils.h>
#import <OneSignalCore/OneSignalClientError.h>
#import <OneSignalCore/OneSignalBadgeHelpers.h>
#import <OneSignalCore/OneSignalVersion.h>

// TODO: Testing: Should this class be defined in this file?
@interface OneSignalCoreImpl : NSObject
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
51 changes: 51 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

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
48 changes: 48 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalVersion.m
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class OSSubscriptionModel: OSModel {
}
}

var sdk = ONESIGNAL_VERSION {
var sdk = OneSignalVersion.numeric() {
didSet {
guard sdk != oldValue else {
return
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 0 additions & 3 deletions iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<OSUser>)User NS_REFINED_FOR_SWIFT;
+ (void)login:(NSString * _Nonnull)externalId;
Expand Down
Loading