Skip to content

Commit a5498b0

Browse files
committed
add getTags public method
* Add `getTags` public method that will return local tags for the current user * Rename an existing internal `getTags` method used for IAM processing by appending the internal keyword. I chose not to combine these two methods as one may be called without privacy consent while the public one should be guarded for privacy consent.
1 parent e1e02a2 commit a5498b0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ - (instancetype _Nonnull)initWithMessage:(OSInAppMessageInternal *)inAppMessage
5353

5454
- (NSString *)getTagsString {
5555
NSError *error;
56-
NSDictionary<NSString *, NSString*> *tags = [OneSignalUserManagerImpl.sharedInstance getTags];
56+
NSDictionary<NSString *, NSString*> *tags = [OneSignalUserManagerImpl.sharedInstance getTagsInternal];
5757
if (tags == nil || tags.count <= 0 ) {
5858
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"[getTagsString] no tags found for the player"];
5959
return nil;

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import OneSignalNotifications
5858
func addTags(_ tags: [String: String])
5959
func removeTag(_ tag: String)
6060
func removeTags(_ tags: [String])
61+
func getTags() -> [String: String]
6162
// Email
6263
func addEmail(_ email: String)
6364
func removeEmail(_ email: String)
@@ -466,7 +467,7 @@ public class OneSignalUserManagerImpl: NSObject, OneSignalUserManager {
466467
}
467468

468469
@objc
469-
public func getTags() -> [String: String]? {
470+
public func getTagsInternal() -> [String: String]? {
470471
guard let user = _user else {
471472
return nil
472473
}
@@ -661,6 +662,13 @@ extension OneSignalUserManagerImpl: OSUser {
661662
user.removeTags(tags)
662663
}
663664

665+
public func getTags() -> [String: String] {
666+
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "getTags") else {
667+
return [:]
668+
}
669+
return user.propertiesModel.tags
670+
}
671+
664672
public func addEmail(_ email: String) {
665673
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "addEmail") else {
666674
return

0 commit comments

Comments
 (0)