diff --git a/android/ably-agent.gradle b/android/ably-agent.gradle new file mode 100644 index 000000000..896d14335 --- /dev/null +++ b/android/ably-agent.gradle @@ -0,0 +1,16 @@ +import java.util.regex.Matcher +import java.util.regex.Pattern + +String dartPackageVersion +String yaml = new File(project.projectDir.parentFile, 'pubspec.yaml').text +Matcher versionMatcher = Pattern.compile("^version:\\s*(.*)\$", Pattern.MULTILINE).matcher(yaml) +if (versionMatcher.find()) { + dartPackageVersion = versionMatcher.group(1) +} + + +android { + defaultConfig { + buildConfigField 'String', 'FLUTTER_PACKAGE_PLUGIN_VERSION', "\"${dartPackageVersion}\"" + } +} diff --git a/android/build.gradle b/android/build.gradle index f740cda99..5b427576c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,7 @@ rootProject.allprojects { apply plugin: 'com.android.library' dependencies { - implementation 'io.ably:ably-android:1.2.7' + implementation 'io.ably:ably-android:1.2.10' implementation 'com.google.firebase:firebase-messaging:22.0.0' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' } @@ -52,3 +52,5 @@ android { disable 'InvalidPackage' } } + +apply from: file("./ably-agent.gradle") diff --git a/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java b/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java index 1df0c7ab5..d81413a4d 100644 --- a/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java +++ b/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java @@ -308,6 +308,9 @@ private PlatformClientOptions decodeClientOptions(Map jsonMap) { readValueFromJson(jsonMap, PlatformConstants.TxClientOptions.channelRetryTimeout, v -> o.channelRetryTimeout = (Integer) v); readValueFromJson(jsonMap, PlatformConstants.TxClientOptions.transportParams, v -> o.transportParams = (Param[]) v); + o.agents = new HashMap<>(); + o.agents.put("ably-flutter", BuildConfig.FLUTTER_PACKAGE_PLUGIN_VERSION); + return new PlatformClientOptions(o, jsonMap.containsKey(PlatformConstants.TxClientOptions.hasAuthCallback) ? ((boolean) jsonMap.get(PlatformConstants.TxClientOptions.hasAuthCallback)) : false); } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 9c08e51e2..0a2aa3ac4 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,7 +2,7 @@ PODS: - Ably (1.2.6): - AblyDeltaCodec (= 1.3.1) - msgpack (= 0.4.0) - - ably_flutter (0.0.5): + - ably_flutter (1.2.2-preview.1): - Ably (= 1.2.6) - Flutter - AblyDeltaCodec (1.3.1) @@ -45,7 +45,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Ably: 6f58ab63407c71f984ef61112f60525cf9bc634a - ably_flutter: 80537c79ba7cdb1ced594e45c2089bc3ffee1349 + ably_flutter: 5dbbb85679f473af0eb56536d2041fadeb9308eb AblyDeltaCodec: f66a44f743b2a0703f29a65208321d4ea43362d6 device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 1b1189f2e..16396c3bf 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -43,7 +43,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - launchStyle = "1" + launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" diff --git a/ios/Classes/codec/AblyFlutterReader.m b/ios/Classes/codec/AblyFlutterReader.m index bbbbb8e99..1bc28eb59 100644 --- a/ios/Classes/codec/AblyFlutterReader.m +++ b/ios/Classes/codec/AblyFlutterReader.m @@ -144,6 +144,8 @@ use an explicitly received null from Dart (manifesting this side as a nil id) // httpMaxRetryCount, realtimeRequestTimeout, fallbackRetryTimeout, // channelRetryTimeout, transportParams, asyncHttpThreadpoolSize, pushFullWait // track @ https://github.com/ably/ably-flutter/issues/14 + + [o addAgent:@"ably-flutter" version: FLUTTER_PACKAGE_PLUGIN_VERSION]; AblyFlutterClientOptions *const co = [AblyFlutterClientOptions new]; ON_VALUE(^(const id value) { diff --git a/ios/ably_flutter.podspec b/ios/ably_flutter.podspec index 6a24e6799..9b2e881a3 100644 --- a/ios/ably_flutter.podspec +++ b/ios/ably_flutter.podspec @@ -2,9 +2,14 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # Run `pod lib lint ably_flutter.podspec` to validate before publishing. # +require 'yaml' + +pubspec = YAML.load_file(File.join('..', 'pubspec.yaml')) +flutter_package_plugin_version = pubspec['version'].gsub('+', '-') + Pod::Spec.new do |s| s.name = 'ably_flutter' - s.version = '0.0.5' + s.version = flutter_package_plugin_version s.summary = 'Ably Cocoa platform support for our Flutter plugin.' s.homepage = 'https://www.ably.com/' s.license = 'Apache 2.0' @@ -18,6 +23,10 @@ Pod::Spec.new do |s| s.ios.deployment_target = '10.0' # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64', + 'GCC_PREPROCESSOR_DEFINITIONS' => "FLUTTER_PACKAGE_PLUGIN_VERSION=\\@\\\"#{flutter_package_plugin_version}\\\"" + } s.swift_version = '5.0' end diff --git a/test_integration/ios/Podfile.lock b/test_integration/ios/Podfile.lock index c5f1837b9..757e33c80 100644 --- a/test_integration/ios/Podfile.lock +++ b/test_integration/ios/Podfile.lock @@ -2,7 +2,7 @@ PODS: - Ably (1.2.6): - AblyDeltaCodec (= 1.3.1) - msgpack (= 0.4.0) - - ably_flutter (0.0.5): + - ably_flutter (1.2.2-preview.1): - Ably (= 1.2.6) - Flutter - AblyDeltaCodec (1.3.1) @@ -27,7 +27,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Ably: 6f58ab63407c71f984ef61112f60525cf9bc634a - ably_flutter: 80537c79ba7cdb1ced594e45c2089bc3ffee1349 + ably_flutter: 5dbbb85679f473af0eb56536d2041fadeb9308eb AblyDeltaCodec: f66a44f743b2a0703f29a65208321d4ea43362d6 Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a msgpack: c85f6251873059738472ae136951cec5f30f3251