3737#import < objc/runtime.h>
3838#import < objc/message.h>
3939
40- LeanplumMessageMatchResult LeanplumMessageMatchResultMake (BOOL matchedTrigger, BOOL matchedUnlessTrigger, BOOL matchedLimit)
40+ LeanplumMessageMatchResult LeanplumMessageMatchResultMake (BOOL matchedTrigger, BOOL matchedUnlessTrigger, BOOL matchedLimit, BOOL matchedActivePeriod )
4141{
4242 LeanplumMessageMatchResult result;
4343 result.matchedTrigger = matchedTrigger;
4444 result.matchedUnlessTrigger = matchedUnlessTrigger;
4545 result.matchedLimit = matchedLimit;
46+ result.matchedActivePeriod = matchedActivePeriod;
4647 return result;
4748}
4849
@@ -1064,7 +1065,7 @@ - (LeanplumMessageMatchResult)shouldShowMessage:(NSString *)messageId
10641065 withEventName : (NSString *)eventName
10651066 contextualValues : (LPContextualValues *)contextualValues
10661067{
1067- LeanplumMessageMatchResult result = LeanplumMessageMatchResultMake (NO , NO , NO );
1068+ LeanplumMessageMatchResult result = LeanplumMessageMatchResultMake (NO , NO , NO , NO );
10681069
10691070 // 1. Must not be muted.
10701071 if ([[NSUserDefaults standardUserDefaults ] boolForKey:
@@ -1088,6 +1089,13 @@ - (LeanplumMessageMatchResult)shouldShowMessage:(NSString *)messageId
10881089 // 3. Must match all limit conditions.
10891090 NSDictionary *limitConfig = messageConfig[@" whenLimits" ];
10901091 result.matchedLimit = [self matchesLimits: limitConfig messageId: messageId];
1092+
1093+ // 4. Must be within active period
1094+ NSTimeInterval now = [[NSDate date ] timeIntervalSince1970 ];
1095+ NSTimeInterval startTime = [messageConfig[@" startTime" ] doubleValue ] / 1000.0 ;
1096+ NSTimeInterval endTime = [messageConfig[@" endTime" ] doubleValue ] / 1000.0 ;
1097+ result.matchedActivePeriod = now > startTime && now < endTime;
1098+
10911099 return result;
10921100}
10931101
0 commit comments