Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 34 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
3C5501402E09CF0100E77DF7 /* OSCopyOnWriteSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C55013E2E09CF0100E77DF7 /* OSCopyOnWriteSet.h */; };
3C5501412E09CF0100E77DF7 /* OSCopyOnWriteSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C55013F2E09CF0100E77DF7 /* OSCopyOnWriteSet.m */; };
3C5501432E09F3D900E77DF7 /* LoggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C5501422E09F3D900E77DF7 /* LoggingTests.swift */; };
3C5C6FFC2FCB8DED00102E2C /* OneSignalIdentifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C5C6FFB2FCB8DED00102E2C /* OneSignalIdentifiers.swift */; };
3C5C6FFD2FCB933100102E2C /* OneSignalOSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C115161289A259500565C41 /* OneSignalOSCore.framework */; };
3C5C70022FCB935000102E2C /* OneSignalOSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C115161289A259500565C41 /* OneSignalOSCore.framework */; };
3C60BB9B2ECF860600C765F7 /* OneSignalInAppMessages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEBAAE282A4211D900BF2C1C /* OneSignalInAppMessages.framework */; };
3C60BB9C2ECF860600C765F7 /* OneSignalInAppMessages.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DEBAAE282A4211D900BF2C1C /* OneSignalInAppMessages.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3C62999F2BEEA34800649187 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3C62999E2BEEA34800649187 /* PrivacyInfo.xcprivacy */; };
Expand Down Expand Up @@ -665,6 +668,20 @@
remoteGlobalIDString = 3C115160289A259500565C41;
remoteInfo = OneSignalOSCore;
};
3C5C6FFF2FCB933100102E2C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 37747F8B19147D6400558FAD /* Project object */;
proxyType = 1;
remoteGlobalIDString = 3C115160289A259500565C41;
remoteInfo = OneSignalOSCore;
};
3C5C70042FCB935000102E2C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 37747F8B19147D6400558FAD /* Project object */;
proxyType = 1;
remoteGlobalIDString = 3C115160289A259500565C41;
remoteInfo = OneSignalOSCore;
};
3C60BB9D2ECF860600C765F7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 37747F8B19147D6400558FAD /* Project object */;
Expand Down Expand Up @@ -1330,6 +1347,7 @@
3C55013E2E09CF0100E77DF7 /* OSCopyOnWriteSet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSCopyOnWriteSet.h; sourceTree = "<group>"; };
3C55013F2E09CF0100E77DF7 /* OSCopyOnWriteSet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSCopyOnWriteSet.m; sourceTree = "<group>"; };
3C5501422E09F3D900E77DF7 /* LoggingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingTests.swift; sourceTree = "<group>"; };
3C5C6FFB2FCB8DED00102E2C /* OneSignalIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneSignalIdentifiers.swift; sourceTree = "<group>"; };
3C62999E2BEEA34800649187 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3C6299A02BEEA38100649187 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3C6299A22BEEA3CC00649187 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1961,9 +1979,10 @@
runOnlyForDeploymentPostprocessing = 0;
};
DE7D17F627026BA3002D3A5D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3C5C70022FCB935000102E2C /* OneSignalOSCore.framework in Frameworks */,

Check failure on line 1985 in iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

View check run for this annotation

Claude / Claude Code Review

Missing OneSignalOSCore dep in podspecs/Package.swift

This PR adds `OneSignalOSCore.framework` to the link phase of the OneSignalExtension and OneSignalNotifications targets (pbxproj lines 1985, 2070) and the implementations now reference `OneSignalIdentifiers` from those binaries, but none of the package manifests declare the new dependency. Customers using the standard NSE integration (CocoaPods `OneSignalXCFramework/OneSignalExtension` or SPM `OneSignalExtension` product) will not get OneSignalOSCore.framework embedded into their NSE target, so
Comment thread
claude[bot] marked this conversation as resolved.
DE7D1846270286C6002D3A5D /* OneSignalCore.framework in Frameworks */,
DE7D18D22703ADE0002D3A5D /* OneSignalOutcomes.framework in Frameworks */,
DE7D1843270283B9002D3A5D /* UserNotifications.framework in Frameworks */,
Expand Down Expand Up @@ -2048,6 +2067,7 @@
DEF7845F2912EA0D00A1F3A5 /* UserNotifications.framework in Frameworks */,
DEF784612912F5E100A1F3A5 /* UIKit.framework in Frameworks */,
DEF784422912E16F00A1F3A5 /* OneSignalCore.framework in Frameworks */,
3C5C6FFD2FCB933100102E2C /* OneSignalOSCore.framework in Frameworks */,
DE2D8F4A2947D86200844084 /* OneSignalOutcomes.framework in Frameworks */,
DE2D8F452947D85800844084 /* OneSignalExtension.framework in Frameworks */,
);
Expand Down Expand Up @@ -2203,6 +2223,7 @@
5BC1DE652C90BC9F00CA8807 /* Consistency */,
3C115163289A259500565C41 /* OneSignalOSCore.h */,
3C115188289ADEA300565C41 /* OSModelStore.swift */,
3C5C6FFB2FCB8DED00102E2C /* OneSignalIdentifiers.swift */,
3C115186289ADE7700565C41 /* OSModelStoreListener.swift */,
3C115184289ADE4F00565C41 /* OSModel.swift */,
3CF1A5622C669EA40056B3AA /* OSNewRecordsState.swift */,
Expand Down Expand Up @@ -3756,6 +3777,7 @@
dependencies = (
DE7D181B27026BEC002D3A5D /* PBXTargetDependency */,
DE7D18D52703ADE0002D3A5D /* PBXTargetDependency */,
3C5C70052FCB935000102E2C /* PBXTargetDependency */,
);
name = OneSignalExtension;
productName = OneSignalExtension;
Expand Down Expand Up @@ -3888,6 +3910,7 @@
DEF784452912E16F00A1F3A5 /* PBXTargetDependency */,
DE2D8F482947D85800844084 /* PBXTargetDependency */,
DE2D8F4D2947D86200844084 /* PBXTargetDependency */,
3C5C70002FCB933100102E2C /* PBXTargetDependency */,
);
name = OneSignalNotifications;
productName = OneSignalNotifications;
Expand Down Expand Up @@ -4350,6 +4373,7 @@
3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */,
5BC1DE5E2C90B80E00CA8807 /* OSCondition.swift in Sources */,
5BC1DE5C2C90B7E600CA8807 /* OSConsistencyManager.swift in Sources */,
3C5C6FFC2FCB8DED00102E2C /* OneSignalIdentifiers.swift in Sources */,
3C115189289ADEA300565C41 /* OSModelStore.swift in Sources */,
3C115185289ADE4F00565C41 /* OSModel.swift in Sources */,
3CF1A5632C669EA40056B3AA /* OSNewRecordsState.swift in Sources */,
Expand Down Expand Up @@ -4795,6 +4819,16 @@
target = 3C115160289A259500565C41 /* OneSignalOSCore */;
targetProxy = 3C115199289AF86C00565C41 /* PBXContainerItemProxy */;
};
3C5C70002FCB933100102E2C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 3C115160289A259500565C41 /* OneSignalOSCore */;
targetProxy = 3C5C6FFF2FCB933100102E2C /* PBXContainerItemProxy */;
};
3C5C70052FCB935000102E2C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 3C115160289A259500565C41 /* OneSignalOSCore */;
targetProxy = 3C5C70042FCB935000102E2C /* PBXContainerItemProxy */;
};
3C60BB9E2ECF860600C765F7 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DEBAAE272A4211D900BF2C1C /* OneSignalInAppMessages */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#import <OneSignalCore/OneSignalCore.h>
#import <OneSignalOSCore/OneSignalOSCore-Swift.h>
#import "OSMacros.h"
#import <OneSignalOutcomes/OneSignalOutcomes.h>
#import "OneSignalNotificationServiceExtensionHandler.h"
Expand Down Expand Up @@ -140,9 +141,8 @@ + (void)onNotificationReceived:(NSString *)receivedNotificationId withBlockingTa
[[OSSessionManager sharedSessionManager] onNotificationReceived:receivedNotificationId];

// Track confirmed delivery
let sharedUserDefaults = OneSignalUserDefaults.initShared;
let playerId = [sharedUserDefaults getSavedStringForKey:OSUD_PUSH_SUBSCRIPTION_ID defaultValue:nil];
let appId = [sharedUserDefaults getSavedStringForKey:OSUD_APP_ID defaultValue:nil];
NSString *playerId = OneSignalIdentifiers.subscriptionId;
NSString *appId = OneSignalIdentifiers.storedAppId;
// Randomize send of confirmed deliveries to lessen traffic for high recipient notifications
int randomDelay = semaphore != nil ? arc4random_uniform(MAX_CONF_DELIVERY_DELAY) : 0;
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"OneSignal onNotificationReceived sendReceiveReceipt with delay: %i", randomDelay]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import <Foundation/Foundation.h>
#import "OneSignalReceiveReceiptsController.h"
#import <OneSignalCore/OneSignalCore.h>
#import <OneSignalOSCore/OneSignalOSCore-Swift.h>
#import "OSMacros.h"
#import "OneSignalExtensionRequests.h"

Expand All @@ -38,9 +39,8 @@ - (BOOL)isReceiveReceiptsEnabled {
}

- (void)sendReceiveReceiptWithNotificationId:(NSString *)notificationId {
let sharedUserDefaults = OneSignalUserDefaults.initShared;
let playerId = [sharedUserDefaults getSavedStringForKey:OSUD_PUSH_SUBSCRIPTION_ID defaultValue:nil];
let appId = [sharedUserDefaults getSavedStringForKey:OSUD_APP_ID defaultValue:nil];
NSString *playerId = OneSignalIdentifiers.subscriptionId;
NSString *appId = OneSignalIdentifiers.storedAppId;

[self sendReceiveReceiptWithPlayerId:playerId
notificationId:notificationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ NS_SWIFT_NAME(onClick(event:));

@property (class, readonly) OneSignalNotificationSettings* _Nonnull osNotificationSettings;

// This is set by the user module
+ (void)setPushSubscriptionId:(NSString *_Nullable)pushSubscriptionId;

+ (void)handleWillShowInForegroundForNotification:(OSNotification *_Nonnull)notification completion:(OSNotificationDisplayResponse _Nonnull)completion;
+ (void)handleNotificationActionWithUrl:(NSString* _Nullable)url actionID:(NSString* _Nonnull)actionID;
+ (void)clearBadgeCount:(BOOL)fromNotifOpened fromClearAll:(BOOL)fromClearAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ of this software and associated documentation files (the "Software"), to deal

#import "OSNotificationsManager.h"
#import <OneSignalCore/OneSignalCore.h>
#import <OneSignalOSCore/OneSignalOSCore-Swift.h>
#import "OSMacros.h"
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
Expand Down Expand Up @@ -231,17 +232,6 @@ + (NSString*)pushToken {
return _pushToken;
}

static NSString *_pushSubscriptionId;
+ (NSString*)pushSubscriptionId {
if (!_pushSubscriptionId) {
_pushSubscriptionId = [OneSignalUserDefaults.initShared getSavedStringForKey:OSUD_PUSH_SUBSCRIPTION_ID defaultValue:nil];
}
return _pushSubscriptionId;
}
+ (void)setPushSubscriptionId:(NSString *)pushSubscriptionId {
_pushSubscriptionId = pushSubscriptionId;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
+ (void)startSwizzling {
Expand Down Expand Up @@ -783,7 +773,7 @@ + (void)submitNotificationOpened:(NSString*)messageId {
NSString* lastMessageId = [standardUserDefaults getSavedStringForKey:OSUD_LAST_MESSAGE_OPENED defaultValue:nil];
//Only submit request if messageId not nil and: (lastMessage is nil or not equal to current one)
if(messageId && (!lastMessageId || ![lastMessageId isEqualToString:messageId])) {
[OneSignalCoreImpl.sharedClient executeRequest:[OSRequestSubmitNotificationOpened withUserId:[self pushSubscriptionId]
[OneSignalCoreImpl.sharedClient executeRequest:[OSRequestSubmitNotificationOpened withUserId:OneSignalIdentifiers.subscriptionId
appId:[OneSignalConfigManager getAppId]
wasOpened:YES
messageId:messageId
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Modified MIT License

Copyright 2026 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
import OneSignalCore

/// Durable accessors for OneSignal identifiers persisted to shared UserDefaults.
/// Useful when the in-memory source isn't available, notably the NSE process
///
/// Callers with access to the in-memory current value (main-app SDK code)
/// should continue to use that source
@objc(OneSignalIdentifiers)
public final class OneSignalIdentifiers: NSObject {

/// Last-known persisted `app_id` from shared UserDefaults. Returns nil if absent.
@objc public static var storedAppId: String? {
return OneSignalUserDefaults.initShared().getSavedString(forKey: OSUD_APP_ID, defaultValue: nil)
}

/// Persisted push `subscription_id` from shared UserDefaults. Returns nil if absent.
@objc public static var subscriptionId: String? {
return OneSignalUserDefaults.initShared().getSavedString(forKey: OSUD_PUSH_SUBSCRIPTION_ID, defaultValue: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,8 @@ extension OSUserExecutor {
areTokensEqual(tokenA: originalPushToken, tokenB: subModel["token"] as? String)
{
OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.hydrate(subModel)
if let subId = subModel["id"] as? String {
OSNotificationsManager.setPushSubscriptionId(subId)
if addNewRecords {
newRecordsState.add(subId)
}
if addNewRecords, let subId = subModel["id"] as? String {
newRecordsState.add(subId)
}
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public class OneSignalUserManagerImpl: NSObject, OneSignalUserManager {
let sharedUserDefaults = OneSignalUserDefaults.initShared()
let reachable = OSNotificationsManager.currentPermissionState.reachable
let token = sharedUserDefaults.getSavedString(forKey: OSUD_PUSH_TOKEN, defaultValue: nil)
let subscriptionId = subscriptionId ?? sharedUserDefaults.getSavedString(forKey: OSUD_PUSH_SUBSCRIPTION_ID, defaultValue: nil)
let subscriptionId = subscriptionId ?? OneSignalIdentifiers.subscriptionId

return OSSubscriptionModel(type: .push,
address: token,
Expand Down
29 changes: 8 additions & 21 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#import "OneSignalFramework.h"
#import <OneSignalOSCore/OneSignalOSCore-Swift.h>
#import "OneSignalInternal.h"
#import "OneSignalTracker.h"
#import "OneSignalTrackIAP.h"
Expand Down Expand Up @@ -236,17 +237,6 @@ + (void)initialize:(nonnull NSString*)newAppId withLaunchOptions:(nullable NSDic
[self init];
}

+ (NSString * _Nullable)getCachedAppId {
let prevAppId = [OneSignalUserDefaults.initStandard getSavedStringForKey:OSUD_APP_ID defaultValue:nil];
if (!prevAppId) {
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:@"Waiting for setAppId(appId) with a valid appId to complete OneSignal init!"];
} else {
let logMessage = [NSString stringWithFormat:@"Initializing OneSignal with cached appId: '%@'.", prevAppId];
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:logMessage];
}
return prevAppId;
}

/*
1/2 steps in OneSignal init, relying on setLaunchOptions (usage order does not matter)
Sets the app id OneSignal should use in the application
Expand All @@ -257,10 +247,12 @@ + (void)setAppId:(nullable NSString*)newAppId {
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"setAppId called with appId: %@!", newAppId]];

if (!newAppId || newAppId.length == 0) {
NSString* cachedAppId = [self getCachedAppId];
NSString* cachedAppId = OneSignalIdentifiers.storedAppId;
if (cachedAppId) {
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:[NSString stringWithFormat:@"Initializing OneSignal with cached appId: '%@'.", cachedAppId]];
[OneSignalConfigManager setAppId:cachedAppId];
} else {
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:@"Waiting for setAppId(appId) with a valid appId to complete OneSignal init!"];
return;
}
} else if ([OneSignalConfigManager getAppId] && ![newAppId isEqualToString:[OneSignalConfigManager getAppId]]) {
Expand Down Expand Up @@ -533,7 +525,7 @@ + (void)handleAppIdChange:(NSString*)appId {
}

let standardUserDefaults = OneSignalUserDefaults.initStandard;
let prevAppId = [standardUserDefaults getSavedStringForKey:OSUD_APP_ID defaultValue:nil];
NSString *prevAppId = OneSignalIdentifiers.storedAppId;

// Handle changes to the app id, this might happen on a developer's device when testing
// Will also run the first time OneSignal is initialized
Expand All @@ -543,22 +535,17 @@ + (void)handleAppIdChange:(NSString*)appId {
_didCallDownloadParameters = false;

let sharedUserDefaults = OneSignalUserDefaults.initShared;

[standardUserDefaults saveStringForKey:OSUD_APP_ID withValue:appId];


// Remove player_id from both standard and shared NSUserDefaults
[standardUserDefaults removeValueForKey:OSUD_PUSH_SUBSCRIPTION_ID];
[sharedUserDefaults removeValueForKey:OSUD_PUSH_SUBSCRIPTION_ID];
[standardUserDefaults removeValueForKey:OSUD_LEGACY_PLAYER_ID];
[sharedUserDefaults removeValueForKey:OSUD_LEGACY_PLAYER_ID];

// Clear all cached data, does not start User Module nor call logout.
[OneSignalUserManagerImpl.sharedInstance clearAllModelsFromStores];
}

// Always save appId and player_id as it will not be present on shared if:
// - Updating from an older SDK
// - Updating to an app that didn't have App Groups setup before

[OneSignalUserDefaults.initShared saveStringForKey:OSUD_APP_ID withValue:appId];
}

Expand Down
Loading