@@ -72,7 +72,7 @@ - (void)startWithConfig:(CountlyConfig *)config
72
72
73
73
COUNTLY_LOG (@" Initializing with %@ SDK v%@ " , kCountlySDKName , kCountlySDKVersion );
74
74
75
- if (!CountlyDeviceInfo.sharedInstance .deviceID || config.forceDeviceIDInitialization )
75
+ if (!CountlyDeviceInfo.sharedInstance .deviceID || config.resetStoredDeviceID )
76
76
[CountlyDeviceInfo.sharedInstance initializeDeviceID: config.deviceID];
77
77
78
78
CountlyConnectionManager.sharedInstance .appKey = config.appKey ;
@@ -83,7 +83,7 @@ - (void)startWithConfig:(CountlyConfig *)config
83
83
CountlyConnectionManager.sharedInstance .customHeaderFieldName = config.customHeaderFieldName ;
84
84
CountlyConnectionManager.sharedInstance .customHeaderFieldValue = config.customHeaderFieldValue ;
85
85
CountlyConnectionManager.sharedInstance .secretSalt = config.secretSalt ;
86
- CountlyConnectionManager.sharedInstance .applyZeroIDFAFix = config.applyZeroIDFAFix ;
86
+ CountlyConnectionManager.sharedInstance .URLSessionConfiguration = config.URLSessionConfiguration ;
87
87
88
88
CountlyPersistency.sharedInstance .eventSendThreshold = config.eventSendThreshold ;
89
89
CountlyPersistency.sharedInstance .storedRequestsLimit = MAX (1 , config.storedRequestsLimit );
@@ -121,7 +121,7 @@ - (void)startWithConfig:(CountlyConfig *)config
121
121
if ([config.features containsObject: CLYPushNotifications])
122
122
{
123
123
CountlyPushNotifications.sharedInstance .isEnabledOnInitialConfig = YES ;
124
- CountlyPushNotifications.sharedInstance .isTestDevice = config.isTestDevice ;
124
+ CountlyPushNotifications.sharedInstance .pushTestMode = config.pushTestMode ;
125
125
CountlyPushNotifications.sharedInstance .sendPushTokenAlways = config.sendPushTokenAlways ;
126
126
CountlyPushNotifications.sharedInstance .doNotShowAlertForNotifications = config.doNotShowAlertForNotifications ;
127
127
CountlyPushNotifications.sharedInstance .launchNotification = config.launchNotification ;
@@ -137,10 +137,6 @@ - (void)startWithConfig:(CountlyConfig *)config
137
137
}
138
138
#endif
139
139
140
- // NOTE: Disable APM feature until server completely supports it
141
- // if ([config.features containsObject:CLYAPM])
142
- // [CountlyAPM.sharedInstance startAPM];
143
-
144
140
timer = [NSTimer scheduledTimerWithTimeInterval: config.updateSessionPeriod target: self selector: @selector (onTimer: ) userInfo: nil repeats: YES ];
145
141
[NSRunLoop .mainRunLoop addTimer: timer forMode: NSRunLoopCommonModes ];
146
142
@@ -163,25 +159,34 @@ - (void)setNewDeviceID:(NSString *)deviceID onServer:(BOOL)onServer
163
159
if (!CountlyConsentManager.sharedInstance .hasAnyConsent )
164
160
return ;
165
161
166
- #pragma GCC diagnostic push
167
- #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
162
+ deviceID = [CountlyDeviceInfo.sharedInstance ensafeDeviceID: deviceID];
168
163
169
- #if TARGET_OS_IOS
170
- if ([deviceID isEqualToString: CLYIDFA])
171
- deviceID = [CountlyDeviceInfo.sharedInstance zeroSafeIDFA ];
172
- else if ([deviceID isEqualToString: CLYIDFV])
173
- deviceID = UIDevice.currentDevice .identifierForVendor .UUIDString ;
174
- else if ([deviceID isEqualToString: CLYOpenUDID])
175
- deviceID = [Countly_OpenUDID value ];
176
- #elif TARGET_OS_OSX
177
- if ([deviceID isEqualToString: CLYOpenUDID])
178
- deviceID = [Countly_OpenUDID value ];
179
- #endif
164
+ if ([deviceID isEqualToString: CountlyDeviceInfo.sharedInstance.deviceID])
165
+ {
166
+ COUNTLY_LOG (@" Attempted to set the same device ID again. So, setting new device ID is aborted." );
167
+ return ;
168
+ }
180
169
181
- #pragma GCC diagnostic pop
170
+ if (CountlyDeviceInfo.sharedInstance .isDeviceIDTemporary )
171
+ {
172
+ COUNTLY_LOG (@" Going out of CLYTemporaryDeviceID mode and switching back to normal mode." );
173
+
174
+ [CountlyDeviceInfo.sharedInstance initializeDeviceID: deviceID];
175
+
176
+ [CountlyPersistency.sharedInstance replaceAllTemporaryDeviceIDsInQueueWithDeviceID: deviceID];
177
+
178
+ [CountlyConnectionManager.sharedInstance proceedOnQueue ];
179
+
180
+ [CountlyRemoteConfig.sharedInstance startRemoteConfig ];
182
181
183
- if ([deviceID isEqualToString: CountlyDeviceInfo.sharedInstance.deviceID])
184
182
return ;
183
+ }
184
+
185
+ if ([deviceID isEqualToString: CLYTemporaryDeviceID] && onServer)
186
+ {
187
+ COUNTLY_LOG (@" Attempted to set device ID as CLYTemporaryDeviceID with onServer option. So, onServer value is overridden as NO." );
188
+ onServer = NO ;
189
+ }
185
190
186
191
if (onServer)
187
192
{
@@ -206,12 +211,30 @@ - (void)setNewDeviceID:(NSString *)deviceID onServer:(BOOL)onServer
206
211
[CountlyRemoteConfig.sharedInstance startRemoteConfig ];
207
212
}
208
213
214
+ - (void )setNewAppKey : (NSString *)newAppKey
215
+ {
216
+ if (!newAppKey.length )
217
+ return ;
218
+
219
+ [self suspend ];
220
+
221
+ CountlyConnectionManager.sharedInstance .appKey = newAppKey;
222
+
223
+ [self resume ];
224
+ }
225
+
209
226
- (void )setCustomHeaderFieldValue : (NSString *)customHeaderFieldValue
210
227
{
211
228
CountlyConnectionManager.sharedInstance .customHeaderFieldValue = customHeaderFieldValue.copy ;
212
229
[CountlyConnectionManager.sharedInstance proceedOnQueue ];
213
230
}
214
231
232
+ - (void )flushQueues
233
+ {
234
+ [CountlyPersistency.sharedInstance flushEvents ];
235
+ [CountlyPersistency.sharedInstance flushQueue ];
236
+ }
237
+
215
238
#pragma mark ---
216
239
217
240
- (void )beginSession
@@ -593,35 +616,20 @@ - (void)crashLog:(NSString *)format, ...
593
616
{
594
617
595
618
}
596
-
597
619
#endif
598
620
599
621
600
622
601
- #pragma mark - APM
602
-
603
- - (void )addExceptionForAPM : (NSString *)exceptionURL
604
- {
605
- [CountlyAPM.sharedInstance addExceptionForAPM: exceptionURL];
606
- }
607
-
608
- - (void )removeExceptionForAPM : (NSString *)exceptionURL
609
- {
610
- [CountlyAPM.sharedInstance removeExceptionForAPM: exceptionURL];
611
- }
612
-
613
-
614
-
615
623
#pragma mark - View Tracking
616
624
617
625
- (void )recordView : (NSString *)viewName ;
618
626
{
619
- [CountlyViewTracking.sharedInstance startView: viewName];
627
+ [CountlyViewTracking.sharedInstance startView: viewName customSegmentation: nil ];
620
628
}
621
629
622
- - (void )reportView : (NSString *)viewName
630
+ - (void )recordView : (NSString *)viewName segmentation : ( NSDictionary *) segmentation
623
631
{
624
-
632
+ [CountlyViewTracking.sharedInstance startView: viewName customSegmentation: segmentation];
625
633
}
626
634
627
635
#if TARGET_OS_IOS
@@ -693,17 +701,17 @@ - (id)remoteConfigValueForKey:(NSString *)key
693
701
694
702
- (void )updateRemoteConfigWithCompletionHandler : (void (^)(NSError * error))completionHandler
695
703
{
696
- [CountlyRemoteConfig.sharedInstance updateRemoteConfigForForKeys :nil omitKeys: nil completionHandler: completionHandler];
704
+ [CountlyRemoteConfig.sharedInstance updateRemoteConfigForKeys :nil omitKeys: nil completionHandler: completionHandler];
697
705
}
698
706
699
707
- (void )updateRemoteConfigOnlyForKeys : (NSArray *)keys completionHandler : (void (^)(NSError * error))completionHandler
700
708
{
701
- [CountlyRemoteConfig.sharedInstance updateRemoteConfigForForKeys : keys omitKeys: nil completionHandler: completionHandler];
709
+ [CountlyRemoteConfig.sharedInstance updateRemoteConfigForKeys : keys omitKeys: nil completionHandler: completionHandler];
702
710
}
703
711
704
712
- (void )updateRemoteConfigExceptForKeys : (NSArray *)omitKeys completionHandler : (void (^)(NSError * error))completionHandler
705
713
{
706
- [CountlyRemoteConfig.sharedInstance updateRemoteConfigForForKeys :nil omitKeys: omitKeys completionHandler: completionHandler];
714
+ [CountlyRemoteConfig.sharedInstance updateRemoteConfigForKeys :nil omitKeys: omitKeys completionHandler: completionHandler];
707
715
}
708
716
709
717
0 commit comments