Skip to content

Commit

Permalink
20.11.2 changes implemented (#35)
Browse files Browse the repository at this point in the history
* 20.11.2 changes implemented
- updateSessionInterval method added
- Deprecated keys issues fixed in pubspec.yaml
- flutter_plugin_android_lifecycle updated to latest version (2.0.1)
- Updated underlying android SDK to 20.11.6
- COUNTLY_EXCLUDE_PUSHNOTIFICATIONS flag added for iOS push.

* Removed extra text from changlelog

* Changlelog updated
  • Loading branch information
ijunaid authored Apr 26, 2021
1 parent 7d523ef commit d200218
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 51 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 20.11.2
* Added COUNTLY_EXCLUDE_PUSHNOTIFICATIONS flag to disable push notifications altogether in order to avoid App Store Connect warnings.
* Add "updateSessionInterval" method to sets the interval for the automatic session update calls
* flutter_plugin_android_lifecycle updated to latest version (2.0.1)
* Added metric for the device manufacturer in underlying android SDK
* Fixed potential issues by sending all available events before the "end session" request in underlying android SDK
* Updated underlying android SDK to 20.11.8
* Underlying iOS SDK version is 20.11.1

## 20.11.1
* Added a way to retrieve feedback widget data and manually report them
* Updated underlying android SDK to 20.11.4
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
## What's Countly?

[Countly](http://count.ly) is an innovative, real-time, open source mobile analytics and push notifications platform. It collects data from mobile devices, and visualizes this information to analyze mobile application usage and end-user behavior. There are two parts of Countly: [the server that collects and analyzes data](http://github.com/countly/countly-server), and mobile SDK that sends this data. Both parts are open source with different licensing terms.
[Countly](https://count.ly) is an innovative, real-time, open source mobile analytics and push notifications platform. It collects data from mobile devices, and visualizes this information to analyze mobile application usage and end-user behavior. There are two parts of Countly: [the server that collects and analyzes data](https://github.com/countly/countly-server), and mobile SDK that sends this data. Both parts are open source with different licensing terms.

* **Slack user?** [Join our Slack community](https://slack.count.ly)
* **Questions?** [Ask in our Community forum](https://community.count.ly)

## About this SDK

This repository includes the Countly Flutter Bridge SDK. See [Countly Flutter Bridge SDK](http://resources.count.ly/docs/flutter) documentation for installation, configuration and usage.
This repository includes the Countly Flutter Bridge SDK. See [Countly Flutter Bridge SDK](https://resources.count.ly/docs/flutter) documentation for installation, configuration and usage.

## Other Github resources ##

This SDK needs one of the following Countly server editions to work:

* Countly Community Edition, [downloadable from Github](https://github.com/Countly/countly-server).
* [Countly Enterprise Edition](http://count.ly/product) with enterprise SLA and support options.
* [Countly Enterprise Edition](https://count.ly/product) with enterprise SLA and support options.

For more information about Countly Enterprise Edition, see [comparison of different Countly Editions](https://count.ly/compare/)

There are also other Countly SDK repositories (both official and community supported) on [Countly Resources](http://resources.count.ly/v1.0/docs/downloading-sdks).
There are also other Countly SDK repositories (both official and community supported) on [Countly Resources](https://resources.count.ly/v1.0/docs/downloading-sdks).

## How can I help you with your efforts? ##

Glad you asked. We need ideas, feedbacks and constructive comments. All your suggestions will be taken care with upmost importance. We are on [Twitter](http://twitter.com/gocountly) and [Facebook](http://www.facebook.com/Countly) if you would like to keep up with our fast progress!
Glad you asked. We need ideas, feedbacks and constructive comments. All your suggestions will be taken care with upmost importance. We are on [Twitter](https://twitter.com/gocountly) and [Facebook](https://www.facebook.com/Countly) if you would like to keep up with our fast progress!

## Badges ##

Expand All @@ -38,4 +38,4 @@ If you like Countly, [why not use one of our badges](https://count.ly/brand-asse

## Support ##

Have any questions? Visit [http://community.count.ly](http://community.count.ly "Countly Community Forum").
Have any questions? Visit [https://community.count.ly](https://community.count.ly "Countly Community Forum").
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ android {
}

dependencies {
implementation 'ly.count.android:sdk:20.11.4'
implementation 'ly.count.android:sdk:20.11.6'
implementation 'com.google.firebase:firebase-messaging:20.2.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
public class CountlyFlutterPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware, DefaultLifecycleObserver {

private static final String TAG = "CountlyFlutterPlugin";
private String COUNTLY_FLUTTER_SDK_VERSION_STRING = "20.11.1";
private String COUNTLY_FLUTTER_SDK_VERSION_STRING = "20.11.2";
private String COUNTLY_FLUTTER_SDK_NAME = "dart-flutterb-android";
/** Plugin registration. */
private Countly.CountlyMessagingMode pushTokenType = Countly.CountlyMessagingMode.PRODUCTION;
Expand Down Expand Up @@ -420,6 +420,11 @@ public void run() {
} else if ("updateSessionPeriod".equals(call.method)) {
result.success("default!");

} else if ("updateSessionInterval".equals(call.method)) {
int sessionInterval = Integer.parseInt(args.getString(0));
this.config.setUpdateSessionTimerDelay(sessionInterval);
result.success("updateSessionInterval Success!");

} else if ("eventSendThreshold".equals(call.method)) {
int queueSize = Integer.parseInt(args.getString(0));
this.config.setEventQueueSizeToSend(queueSize);
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Flutter/Flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#

Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => '[email protected]' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.vendored_frameworks = 'Flutter.framework'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- countly_flutter (20.11.1):
- countly_flutter (20.11.2):
- Flutter
- Flutter (1.0.0)

Expand All @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: Flutter

SPEC CHECKSUMS:
countly_flutter: ac272dbe94b6239007afc208656d6534a19b78a1
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
countly_flutter: 266e853e7df5f1ebcac2c6719d2088380c9420af
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

COCOAPODS: 1.9.3
COCOAPODS: 1.10.1
19 changes: 0 additions & 19 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
8BBBA8CD2370080200543AAF /* Embed App Extensions */,
6093F0C073FA0FD024D7B2DA /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -308,24 +307,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
6093F0C073FA0FD024D7B2DA /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @dart=2.9
import 'dart:io';

import 'package:flutter/material.dart';
Expand Down
23 changes: 21 additions & 2 deletions ios/Classes/CountlyFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @interface CountlyFeedbackWidget ()
+ (CountlyFeedbackWidget *)createWithDictionary:(NSDictionary *)dictionary;
@end

NSString* const kCountlyFlutterSDKVersion = @"20.11.1";
NSString* const kCountlyFlutterSDKVersion = @"20.11.2";
NSString* const kCountlyFlutterSDKName = @"dart-flutterb-ios";

FlutterResult notificationListener = nil;
Expand Down Expand Up @@ -64,9 +64,13 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {

//should only be used for silent pushes if explicitly enabled
//config.sendPushTokenAlways = YES;
#if (TARGET_OS_IOS)
#ifndef COUNTLY_EXCLUDE_PUSHNOTIFICATIONS
if(enablePushNotifications) {
[self addCountlyFeature:CLYPushNotifications];
}
#endif
#endif

if(command.count == 3){
deviceID = [command objectAtIndex:2];
Expand Down Expand Up @@ -200,10 +204,21 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
result(@"updateSessionPeriod!");
});

}else if ([@"updateSessionInterval" isEqualToString:call.method]) {
dispatch_async(dispatch_get_main_queue(), ^ {
@try{
int sessionInterval = [[command objectAtIndex:0] intValue];
config.updateSessionPeriod = sessionInterval;
result(@"updateSessionInterval Success!");
}
@catch(NSException *exception){
COUNTLY_FLUTTER_LOG(@"Exception occurred at updateSessionInterval method: %@", exception);
};
});
}else if ([@"eventSendThreshold" isEqualToString:call.method]) {
dispatch_async(dispatch_get_main_queue(), ^ {
@try{
int limit = [[command objectAtIndex:1] intValue];
int limit = [[command objectAtIndex:0] intValue];
config.eventSendThreshold = limit;
result(@"eventSendThreshold!");
}
Expand Down Expand Up @@ -387,9 +402,13 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
});
result(@"disablePushNotifications!");
}else if ([@"askForNotificationPermission" isEqualToString:call.method]) {
#if (TARGET_OS_IOS)
#ifndef COUNTLY_EXCLUDE_PUSHNOTIFICATIONS
dispatch_async(dispatch_get_main_queue(), ^ {
[Countly.sharedInstance askForNotificationPermission];
});
#endif
#endif
result(@"askForNotificationPermission!");
}else if ([@"pushTokenType" isEqualToString:call.method]) {
dispatch_async(dispatch_get_main_queue(), ^ {
Expand Down
2 changes: 1 addition & 1 deletion ios/countly_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'countly_flutter'
s.version = '20.11.1'
s.version = '20.11.2'
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
s.homepage = 'https://github.com/Countly/countly-sdk-flutter-bridge'
s.social_media_url = 'https://twitter.com/gocountly'
Expand Down
41 changes: 33 additions & 8 deletions lib/countly_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class Countly {
/// its value should be updated from [setLoggingEnabled(bool flag)].
static bool _isDebug = false;

static final String TAG = "CountlyFlutter";
/// Used to determine if init is called.
/// its value should be updated from [init(...)].
static bool _isInitialized = false;

static final String tag = "CountlyFlutter";

/// Flag to determine if crash logging functionality should be enabled
/// If false the intercepted crashes will be ignored
Expand All @@ -33,10 +37,11 @@ class Countly {
static log(String message, {LogLevel logLevel = LogLevel.DEBUG}) async {
String logLevelStr = describeEnum(logLevel);
if(_isDebug){
print('[$TAG] ${logLevelStr}: ${message}');
print('[$tag] $logLevelStr: $message');
}
}
static Future<String> init(String serverUrl, String appKey, [String deviceId]) async {
_isInitialized = true;
if (Platform.isAndroid) {
messagingMode = {"TEST": "2", "PRODUCTION": "0"};
}
Expand Down Expand Up @@ -71,9 +76,9 @@ class Countly {
/// In request queue, if there are any request whose app key is different than the current app key,
/// these requests' app key will be replaced with the current app key.
static Future<String> replaceAllAppKeysInQueueWithCurrentAppKey() async {
final String result = await _channel.invokeMethod('replaceAllAppKeysInQueueWithCurrentAppKey');
log(result);
return result;
final String result = await _channel.invokeMethod('replaceAllAppKeysInQueueWithCurrentAppKey');
log(result);
return result;
}

/// Removes all requests with a different app key in request queue.
Expand Down Expand Up @@ -274,7 +279,7 @@ class Countly {

/// Set callback to receive push notifications
/// @param { callback listner } callback
static Future<String> onNotification(Function callback) async {
static Future<String> onNotification(Function callback) async {
List <String> args = [];
listenerCallback = callback;
log("registerForNotification");
Expand Down Expand Up @@ -329,6 +334,26 @@ static Future<String> onNotification(Function callback) async {
return result;
}

/// Sets the interval for the automatic session update calls
/// min value 1 (1 second),
/// max value 600 (10 minutes)
/// [int sessionInterval]- delay in seconds
static Future<String> updateSessionInterval(int sessionInterval) async {
if(_isInitialized) {
log('updateSessionInterval should be called before init',logLevel: LogLevel.WARNING);
return "updateSessionInterval should be called before init";
}
List <String> args = [];
args.add(sessionInterval.toString());
log(args.toString());
final String result = await _channel.invokeMethod('updateSessionInterval', <String, dynamic>{
'data': json.encode(args)
});
log(result);
return result;

}

/// Events get grouped together and are sent either every minute or after the unsent event count reaches a threshold. By default it is 10
/// Should be call before Countly init
static Future<String> eventSendThreshold(int limit) async {
Expand Down Expand Up @@ -390,7 +415,7 @@ static Future<String> onNotification(Function callback) async {
log(result);
return result;
}

/// Get currently used device Id.
/// Should be call after Countly init
static Future<String> getCurrentDeviceId() async {
Expand Down Expand Up @@ -1266,7 +1291,7 @@ static Future<String> onNotification(Function callback) async {
List <String> args = [];
log(args.toString());
final String result = await _channel.invokeMethod('enableApm', <String, dynamic>{
'data': json.encode(args)
'data': json.encode(args)
});
log(result);
return result;
Expand Down
15 changes: 10 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: countly_flutter
description: Countly is an innovative, real-time, open source mobile analytics and push notifications platform. It collects data from mobile devices, and visualizes this information to analyze mobile application usage and end-user behavior. There are two parts of Countly, the server that collects and analyzes data, and mobile SDK that sends this data. Both parts are open source with different licensing terms.
version: 20.11.1
description: Countly is an innovative, real-time, open source mobile analytics and push notifications platform.
version: 20.11.2
homepage: https://support.count.ly/hc/en-us/articles/360037944212-Flutter

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.0.0"

dependencies:
flutter_plugin_android_lifecycle: ^1.0.8
flutter_plugin_android_lifecycle: ^2.0.1
flutter:
sdk: flutter

Expand All @@ -18,5 +18,10 @@ dev_dependencies:

flutter:
plugin:
androidPackage: ly.count.dart.countly_flutter
pluginClass: CountlyFlutterPlugin
platforms:
android:
package: ly.count.dart.countly_flutter
pluginClass: CountlyFlutterPlugin
ios:
pluginClass: CountlyFlutterPlugin

0 comments on commit d200218

Please sign in to comment.