16
16
#import " BNCLog.h"
17
17
#import " Branch.h"
18
18
#import " NSString+Branch.h"
19
+ #import " BNCApplication.h"
19
20
20
21
@interface BNCServerInterface ()
21
22
@property (strong ) NSString *requestEndpoint;
@@ -528,6 +529,12 @@ - (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict {
528
529
[self safeSetValue: [deviceInfo userAgentString ] forKey: @" user_agent" onDict: dict];
529
530
530
531
[self safeSetValue: [deviceInfo optedInStatus ] forKey: BRANCH_REQUEST_KEY_OPTED_IN_STATUS onDict: dict];
532
+
533
+ if ([self installDateIsRecent ] && [deviceInfo isFirstOptIn ]) {
534
+ [self safeSetValue: @(deviceInfo.isFirstOptIn) forKey: BRANCH_REQUEST_KEY_FIRST_OPT_IN onDict: dict];
535
+ [BNCPreferenceHelper preferenceHelper ].hasOptedInBefore = YES ;
536
+ }
537
+
531
538
[self safeSetValue: @(deviceInfo.isAdTrackingEnabled) forKey: BRANCH_REQUEST_KEY_AD_TRACKING_ENABLED onDict: dict];
532
539
533
540
[self safeSetValue: deviceInfo.applicationVersion forKey: @" app_version" onDict: dict];
@@ -541,6 +548,20 @@ - (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict {
541
548
}
542
549
}
543
550
551
+ // we do not need to send first_opt_in, if the install is older than 30 days
552
+ - (BOOL )installDateIsRecent {
553
+ // NSTimeInterval maxTimeSinceInstall = 60.0;
554
+ NSTimeInterval maxTimeSinceInstall = 3600.0 * 24.0 * 30 ;
555
+ NSDate *now = [NSDate date ];
556
+ NSDate *maxDate = [[BNCApplication currentApplication ].currentInstallDate dateByAddingTimeInterval: maxTimeSinceInstall];
557
+
558
+ if ([now compare: maxDate] == NSOrderedDescending) {
559
+ return NO ;
560
+ } else {
561
+ return YES ;
562
+ }
563
+ }
564
+
544
565
- (NSMutableDictionary *)updateDeviceInfoToParams : (NSDictionary *)params {
545
566
NSMutableDictionary *extendedParams=[[NSMutableDictionary alloc ] init ];
546
567
[extendedParams addEntriesFromDictionary: params];
0 commit comments