Skip to content

Commit d3eb08d

Browse files
committed
public updateUserJwt method
public updateUserJwt method
1 parent ec84c2c commit d3eb08d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ import OneSignalOSCore
3030
import OneSignalNotifications
3131

3232
/**
33-
Public-facing API to access the User Manager.
33+
Internal API to access the User Manager.
3434
*/
3535
@objc protocol OneSignalUserManager {
3636
// swiftlint:disable identifier_name
3737
var User: OSUser { get }
3838
func login(externalId: String, token: String?)
3939
func logout()
40+
func updateUserJwt(externalId: String, token: String)
4041
// Location
4142
func setLocation(latitude: Float, longitude: Float)
4243
// Purchase Tracking
@@ -525,6 +526,16 @@ public class OneSignalUserManagerImpl: NSObject, OneSignalUserManager {
525526
updatePropertiesDeltas(property: .purchases, value: purchases)
526527
}
527528

529+
@objc
530+
public func updateUserJwt(externalId: String, token: String) {
531+
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "updateUserJwt") else {
532+
return
533+
}
534+
OneSignalLog.onesignalLog(ONE_S_LOG_LEVEL.LL_VERBOSE, message: "Update User JWT called with externalId: \(externalId) and token: \(token)")
535+
536+
identityModelRepo.updateJwtToken(externalId: externalId, token: token)
537+
}
538+
528539
private func fireJwtExpired() {
529540
guard let externalId = user.identityModel.externalId, let jwtExpiredHandler = self.jwtExpiredHandler else {
530541
return

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ + (void)logout {
208208
[OneSignalUserManagerImpl.sharedInstance logout];
209209
}
210210

211+
+ (void)updateUserJwt:(NSString * _Nonnull)externalId withToken:(NSString * _Nonnull)token {
212+
if ([OneSignalConfigManager shouldAwaitAppIdAndLogMissingPrivacyConsentForMethod:@"updateUserJwt"]) {
213+
return;
214+
}
215+
[OneSignalUserManagerImpl.sharedInstance updateUserJwtWithExternalId:externalId token:token];
216+
}
217+
211218
#pragma mark: Namespaces
212219

213220
+ (Class<OSNotifications>)Notifications {

iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typedef void (^OSFailureBlock)(NSError* error);
7070
+ (void)login:(NSString * _Nonnull)externalId;
7171
+ (void)login:(NSString * _Nonnull)externalId withToken:(NSString * _Nullable)token
7272
NS_SWIFT_NAME(login(externalId:token:));
73+
+ (void)updateUserJwt:(NSString * _Nonnull)externalId withToken:(NSString * _Nonnull)token;
7374
+ (void)logout;
7475

7576
#pragma mark Notifications

0 commit comments

Comments
 (0)