Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ably agent header #188

Merged
merged 10 commits into from Oct 27, 2021
16 changes: 16 additions & 0 deletions 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}\""
}
}
4 changes: 3 additions & 1 deletion android/build.gradle
Expand Up @@ -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'
}
Expand Down Expand Up @@ -52,3 +52,5 @@ android {
disable 'InvalidPackage'
}
}

apply from: file("./ably-agent.gradle")
Expand Up @@ -308,6 +308,9 @@ private PlatformClientOptions decodeClientOptions(Map<String, Object> 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);
}

Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Expand Up @@ -2,7 +2,7 @@ PODS:
- Ably (1.2.6):
- AblyDeltaCodec (= 1.3.1)
- msgpack (= 0.4.0)
- ably_flutter (0.0.5):
owenpearson marked this conversation as resolved.
Show resolved Hide resolved
- ably_flutter (1.2.2-preview.1):
- Ably (= 1.2.6)
- Flutter
- AblyDeltaCodec (1.3.1)
Expand Down Expand Up @@ -45,7 +45,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Ably: 6f58ab63407c71f984ef61112f60525cf9bc634a
ably_flutter: 80537c79ba7cdb1ced594e45c2089bc3ffee1349
ably_flutter: 5dbbb85679f473af0eb56536d2041fadeb9308eb
AblyDeltaCodec: f66a44f743b2a0703f29a65208321d4ea43362d6
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Expand Down
Expand Up @@ -43,7 +43,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "1"
launchStyle = "0"
QuintinWillison marked this conversation as resolved.
Show resolved Hide resolved
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/codec/AblyFlutterReader.m
Expand Up @@ -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) {
Expand Down
13 changes: 11 additions & 2 deletions ios/ably_flutter.podspec
Expand Up @@ -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'
Expand All @@ -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
4 changes: 2 additions & 2 deletions test_integration/ios/Podfile.lock
Expand Up @@ -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)
Expand All @@ -27,7 +27,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Ably: 6f58ab63407c71f984ef61112f60525cf9bc634a
ably_flutter: 80537c79ba7cdb1ced594e45c2089bc3ffee1349
ably_flutter: 5dbbb85679f473af0eb56536d2041fadeb9308eb
AblyDeltaCodec: f66a44f743b2a0703f29a65208321d4ea43362d6
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
msgpack: c85f6251873059738472ae136951cec5f30f3251
Expand Down