Skip to content

Commit ac8e577

Browse files
feat: zone timer to flutter
1 parent cb1fee5 commit ac8e577

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

android/src/main/java/ly/count/dart/countly_flutter/CountlyFlutterPlugin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,10 +1759,15 @@ public void callback(String error) {
17591759
if (_config.has("visibilityTracking")) {
17601760
this.config.experimental.enableVisibilityTracking();
17611761
}
1762+
17621763
if (_config.has("previousNameRecording")) {
17631764
this.config.experimental.enablePreviousNameRecording();
17641765
}
17651766

1767+
if (_config.has("zoneTimerInterval")) {
1768+
this.config.content.setZoneTimerInterval(_config.getInt("zoneTimerInterval"));
1769+
}
1770+
17661771
this.config.content.setGlobalContentCallback(new ContentCallback() {
17671772
@Override
17681773
public void onContentCallback(ContentStatus contentStatus, Map<String, Object> contentData) {

ios/Classes/CountlyFlutterPlugin.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,11 @@ - (void)populateConfig:(NSDictionary *)_config {
17661766

17671767
[_channel invokeMethod:@"contentCallback" arguments:contentCallbackData];
17681768
}];
1769+
1770+
NSNumber *zoneTimerInterval = _config[@"zoneTimerInterval"];
1771+
if (zoneTimerInterval) {
1772+
[config.content setZoneTimerInterval:[zoneTimerInterval unsignedIntValue]];
1773+
}
17691774

17701775
} @catch (NSException *exception) {
17711776
COUNTLY_FLUTTER_LOG(@"[populateConfig], Unable to parse Config object: %@", exception);

ios/Classes/CountlyiOS/CountlyContentConfig.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ - (ContentCallback) getGlobalContentCallback
3939
-(void)setZoneTimerInterval:(NSUInteger)zoneTimerIntervalSeconds
4040
{
4141
if (zoneTimerIntervalSeconds > 15) {
42-
self.zoneTimerInterval = zoneTimerIntervalSeconds;
42+
_zoneTimerInterval = zoneTimerIntervalSeconds;
4343
}
4444
}
4545

4646
- (NSUInteger) getZoneTimerInterval
4747
{
48-
return self.zoneTimerInterval;
48+
return _zoneTimerInterval;
4949
}
5050
#endif
5151

lib/src/configuration_interfaces/countly_config_content.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import '../content_builder.dart';
55
class CountlyConfigContent {
66
/// private variables.
77
ContentCallback? _contentCallback;
8+
int? _zoneTimerInterval;
89

910
/// getters
1011
ContentCallback? get contentCallback => _contentCallback;
12+
int? get zoneTimerInterval => _zoneTimerInterval;
1113

1214
/// setters / methods
1315
@@ -17,4 +19,13 @@ class CountlyConfigContent {
1719
_contentCallback = callback;
1820
return this;
1921
}
20-
}
22+
23+
/// This is an experimental feature and it can have breaking changes
24+
/// Set the interval for the automatic content update calls
25+
///
26+
/// zoneTimerIntervalSeconds in seconds
27+
CountlyConfigContent setZoneTimerInterval(int interval) {
28+
_zoneTimerInterval = interval;
29+
return this;
30+
}
31+
}

lib/src/countly_flutter.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,13 @@ class Countly {
22382238
}
22392239

22402240
/// Experimental END ---------------------------
2241+
2242+
/// Content ---------------------------
2243+
if (config.content.zoneTimerInterval != null) {
2244+
log('"_configToJson", value provided for zoneTimerInterval: [${config.content.zoneTimerInterval}]', logLevel: LogLevel.INFO);
2245+
countlyConfig['zoneTimerInterval'] = config.content.zoneTimerInterval;
2246+
}
2247+
/// Content END ---------------------------
22412248
22422249
/// APM ---------------------------
22432250
if (config.apm.trackAppStartTime) {

0 commit comments

Comments
 (0)