Skip to content

Commit 1f5837f

Browse files
andrejungesdavide-scalzo
authored andcommitted
Implement new method to enable app session customization on iOS (davide-scalzo#133)
1 parent f533d8a commit 1f5837f

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

RNMixpanel/Mixpanel.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,31 @@
201201

202202
/*!
203203
@property
204-
204+
205205
@abstract
206206
If set, determines the background color of mini notifications.
207207
208208
@discussion
209-
If this isn't set, we default to either the color of the UINavigationBar of the top
210-
UINavigationController that is showing when the notification is presented, the
209+
If this isn't set, we default to either the color of the UINavigationBar of the top
210+
UINavigationController that is showing when the notification is presented, the
211211
UINavigationBar default color for the app or the UITabBar default color.
212212
*/
213213
@property (atomic) UIColor* miniNotificationBackgroundColor;
214214

215+
/*!
216+
@property
217+
218+
The minimum session duration (ms) that is tracked in automatic events.
219+
*/
220+
@property (atomic) UInt64 minimumSessionDuration;
221+
222+
/*!
223+
@property
224+
225+
The maximum session duration (ms) that is tracked in automatic events.
226+
*/
227+
@property (atomic) UInt64 maximumSessionDuration;
228+
215229
/*!
216230
@property
217231
@@ -556,10 +570,10 @@
556570

557571
/*!
558572
@method
559-
573+
560574
@abstract
561575
Calls flush, then optionally archives and calls a handler when finished.
562-
576+
563577
@discussion
564578
When calling <code>flush</code> manually, it is sometimes important to verify
565579
that the flush has finished before further action is taken. This is

RNMixpanel/RNMixpanel.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ -(Mixpanel*) getInstance: (NSString *)name {
4646
}
4747
}
4848

49+
// setAppSessionProperties iOS
50+
RCT_EXPORT_METHOD(setAppSessionPropertiesIOS:(NSDictionary *)properties) {
51+
if ([properties objectForKey:@"minimumSessionDuration"]) {
52+
NSNumber *minimumSessionDuration = properties[@"minimumSessionDuration"];
53+
long long int intValue = [minimumSessionDuration longLongValue];
54+
mixpanel.minimumSessionDuration = intValue;
55+
}
56+
57+
if ([properties objectForKey:@"maximumSessionDuration"]) {
58+
NSNumber *maximumSessionDuration = properties[@"maximumSessionDuration"];
59+
long long int intValue = [maximumSessionDuration longLongValue];
60+
mixpanel.maximumSessionDuration = intValue;
61+
}
62+
}
4963

5064
// get distinct id
5165
RCT_EXPORT_METHOD(getDistinctId:(NSString *)apiToken

0 commit comments

Comments
 (0)