Skip to content

Commit 63b034f

Browse files
committed
API for adding triggers has string values
* addTrigger and addTriggers public API will only accept string values, not types string/bool/number, etc. * No logic changes are needed as the SDK already supports string-only trigger values and evaluates booleans and numerics correctly. Tested scenarios with these triggers set via the dashboard on IAMs: 🟢 myTrigger is true 🟡 myTrigger is 1.58 (must pass in "1.58" and not "1.580" for example, the "is" operator does not support numeric equivalence, it arrives to the SDK as value "1.58") 🟢 myTrigger > 5 🟢 myTrigger > 7.689 🟡 myTrigger >= 7.689 (note margin of error due to rounding, this value actually came to the SDK as 7.689000129699707, so adding a trigger value of "7.689" does not trigger the IAM to display)
1 parent 37ad22a commit 63b034f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

iOS_SDK/OneSignalSDK/Source/OneSignalInAppMessaging.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@
9090
- (void)onDidDismissInAppMessage:(OSInAppMessage *_Nonnull)message;
9191
@end
9292

93+
/**
94+
Public API for the InAppMessages namespace.
95+
*/
9396
@protocol OSInAppMessages <NSObject>
9497

95-
+ (void)addTrigger:(NSString * _Nonnull)key withValue:(id _Nonnull)value;
96-
+ (void)addTriggers:(NSDictionary<NSString *, id> * _Nonnull)triggers;
98+
+ (void)addTrigger:(NSString * _Nonnull)key withValue:(NSString * _Nonnull)value;
99+
+ (void)addTriggers:(NSDictionary<NSString *, NSString *> * _Nonnull)triggers;
97100
+ (void)removeTrigger:(NSString * _Nonnull)key;
98101
+ (void)removeTriggers:(NSArray<NSString *> * _Nonnull)keys;
99102
+ (void)clearTriggers;

iOS_SDK/OneSignalSDK/Source/OneSignalInAppMessaging.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ + (void)setLifecycleHandler:(NSObject<OSInAppMessageLifecycleHandler> *_Nullable
4949
[OSMessagingController.sharedInstance setInAppMessageDelegate:delegate];
5050
}
5151

52-
+ (void)addTrigger:(NSString * _Nonnull)key withValue:(id _Nonnull)value {
52+
+ (void)addTrigger:(NSString * _Nonnull)key withValue:(NSString * _Nonnull)value {
5353
// return if the user has not granted privacy permissions
5454
if ([OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:@"addTrigger:withValue:"])
5555
return;
@@ -62,7 +62,7 @@ + (void)addTrigger:(NSString * _Nonnull)key withValue:(id _Nonnull)value {
6262
[OSMessagingController.sharedInstance addTriggers:@{key : value}];
6363
}
6464

65-
+ (void)addTriggers:(NSDictionary<NSString *,id> * _Nonnull)triggers {
65+
+ (void)addTriggers:(NSDictionary<NSString *, NSString *> * _Nonnull)triggers {
6666
// return if the user has not granted privacy permissions
6767
if ([OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:@"addTriggers:"])
6868
return;

0 commit comments

Comments
 (0)