Skip to content

Commit

Permalink
Release Flutter SDK version 8.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hokstuff committed Nov 22, 2023
1 parent daf0285 commit 7ff4c8a
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 50 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 8.0.0

##### Breaking
- Updates the native Android bridge [from Braze Android SDK 27.0.1 to 29.0.1](https://github.com/braze-inc/braze-android-sdk/compare/v27.0.0...v29.0.1#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
- Updates the native iOS bridge [from Braze Swift SDK 6.6.1 to 7.2.0](https://github.com/braze-inc/braze-swift-sdk/compare/6.6.1...7.2.0#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
- Modifies the behavior for Feature Flags methods.
- `BrazePlugin.getFeatureFlagByID(String id)` will now return `null` if the feature flag does not exist.
- `BrazePlugin.subscribeToFeatureFlags(void Function(List<BrazeFeatureFlag>) onEvent))` will only trigger in the following situations:
- When a refresh request completes with success or failure.
- Upon initial subscription if there was previously cached data from the current session.
- The minimum supported Android SDK version is 21.

##### Fixed
- Moved the `compileSDKVersion` for Android down to 33 to match Flutter's versioning.

## 7.0.0

##### Breaking
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Please reach out to support@braze.com regarding any questions or issues.
The `/example` folder contains a sample app illustrating how to integrate and use this package's APIs.

### Requirements
- Dart SDK 2.0.0+
- Dart SDK 2.12.0+
- Flutter SDK 1.10.0+
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,14 +25,14 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 34
compileSdkVersion 33
namespace 'com.braze.brazeplugin'

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 19
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand All @@ -52,5 +52,5 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.braze:android-sdk-ui:27.0.1"
implementation "com.braze:android-sdk-ui:29.0.1"
}
7 changes: 6 additions & 1 deletion android/src/main/kotlin/com/braze/brazeplugin/BrazePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,13 @@ class BrazePlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
brazelog(W) { "Unexpected null id in `getFeatureFlagByID`." }
return
}

val featureFlag = Braze.getInstance(context).getFeatureFlag(ffId)
result.success(featureFlag.forJsonPut().toString())
if (featureFlag == null) {
result.success(null)
} else {
result.success(featureFlag.forJsonPut().toString())
}
}
"getAllFeatureFlags" -> {
val featureFlags = Braze.getInstance(context).getAllFeatureFlags()
Expand Down
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {

defaultConfig {
applicationId "braze.com.brazepluginexample"
minSdkVersion 19
compileSdkVersion 34
minSdkVersion 21
compileSdkVersion flutter.compileSdkVersion
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down Expand Up @@ -102,7 +102,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.multidex:multidex:2.0.1'

implementation "com.braze:android-sdk-ui:27.0.1"
implementation "com.braze:android-sdk-ui:29.0.1"
implementation "com.google.firebase:firebase-messaging:+"
}
apply plugin: 'com.google.gms.google-services'
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
Expand Down
30 changes: 21 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,25 @@ class BrazeFunctionsState extends State<BrazeFunctions> {
child: const Text('GET SINGLE FEATURE FLAG'),
onPressed: () {
String ffId = featureFlagController.text;
print("Showing single feature flag");
if (ffId == "") {
print("No Feature Flag ID entered");
return;
}

_braze.getFeatureFlagByID(ffId).then((ff) {
String ffString = _featureFlagToString(ff);
print(ffString);
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: new Text(ffString),
));
if (ff == null) {
print("No Feature Flag Found with ID: " + ffId);
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: new Text("No Feature Flag Found with ID: " + ffId),
));
} else {
print("Showing single feature flag");
String ffString = _featureFlagToString(ff);
print(ffString);
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: new Text(ffString),
));
}
});
},
),
Expand Down Expand Up @@ -386,15 +398,15 @@ class BrazeFunctionsState extends State<BrazeFunctions> {
var ffProperty;
switch (_featureFlagPropertyType) {
case 'BOOLEAN':
ffProperty = ff.getBooleanProperty(
ffProperty = ff?.getBooleanProperty(
featureFlagPropertyController.text);
break;
case 'NUMBER':
ffProperty = ff.getNumberProperty(
ffProperty = ff?.getNumberProperty(
featureFlagPropertyController.text);
break;
case 'STRING':
ffProperty = ff.getStringProperty(
ffProperty = ff?.getStringProperty(
featureFlagPropertyController.text);
break;
}
Expand Down
10 changes: 7 additions & 3 deletions ios/Classes/BrazePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,13 @@ public class BrazePlugin: NSObject, FlutterPlugin, BrazeDelegate {
print("Unexpected null id in `getFeatureFlagByID`.")
return
}
if let featureFlagJson = BrazePlugin.braze?.featureFlags.featureFlag(id: flagId).json() {
let featureFlagString = String(data: featureFlagJson, encoding: .utf8)
result(featureFlagString)

if let featureFlag = BrazePlugin.braze?.featureFlags.featureFlag(id: flagId),
let featureFlagJson = featureFlag.json() {
let featureFlagString = String(data: featureFlagJson, encoding: .utf8)
result(featureFlagString)
} else {
result(nil)
}
case "getAllFeatureFlags":
let featureFlags = BrazePlugin.braze?.featureFlags.featureFlags.compactMap { flag in
Expand Down
8 changes: 4 additions & 4 deletions ios/braze_plugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'braze_plugin'
s.version = '7.0.0'
s.version = '8.0.0'
s.summary = 'Braze plugin for Flutter.'
s.homepage = 'https://braze.com'
s.license = { :file => '../LICENSE' }
Expand All @@ -14,9 +14,9 @@ Pod::Spec.new do |s|
s.static_framework = true

s.dependency 'Flutter'
s.dependency 'BrazeKit', '~> 6.6.1'
s.dependency 'BrazeLocation', '~> 6.6.1'
s.dependency 'BrazeUI', '~> 6.6.1'
s.dependency 'BrazeKit', '~> 7.2.0'
s.dependency 'BrazeLocation', '~> 7.2.0'
s.dependency 'BrazeUI', '~> 7.2.0'

s.ios.deployment_target = '11.0'
end
5 changes: 3 additions & 2 deletions lib/braze_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,12 @@ class BrazePlugin {
}

/// Get a single Feature Flag.
Future<BrazeFeatureFlag> getFeatureFlagByID(String id) {
/// Returns null if there is no feature flag with that ID.
Future<BrazeFeatureFlag?> getFeatureFlagByID(String id) {
final Map<String, dynamic> params = <String, dynamic>{"id": id};
return _channel
.invokeMethod('getFeatureFlagByID', params)
.then<BrazeFeatureFlag>((dynamic result) => BrazeFeatureFlag(result));
.then<BrazeFeatureFlag?>((dynamic result) => result == null ? null : BrazeFeatureFlag(result));
}

/// Get all Feature Flags from current cache.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: braze_plugin
description: This is the Braze plugin for Flutter. Effective marketing automation is an essential part of successfully scaling and managing your business.
version: 7.0.0
version: 8.0.0
homepage: https://www.braze.com/
repository: https://github.com/braze-inc/braze-flutter-sdk

Expand Down
68 changes: 47 additions & 21 deletions test/braze_plugin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void main() {
final String mockContentCardJson =
"{\"ca\":1234567890,\"cl\":false,\"db\":true,\"dm\":\"\",\"ds\":\"Description of Card\",\"e\":{\"timestamp\":\"1234567890\"},\"ea\":1234567890,\"id\":\"someID=\",\"p\":false,\"r\":false,\"t\":false,\"tp\":\"short_news\",\"tt\":\"Title of Card\",\"uw\":true,\"v\":false}";

bool nullFeatureFlag = false;

setUpAll(() async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannel('braze_plugin'),
Expand All @@ -30,7 +32,7 @@ void main() {
case 'getAllFeatureFlags':
return List<String>.generate(1, (index) => mockFeatureFlagJson);
case 'getFeatureFlagByID':
return mockFeatureFlagJson;
return nullFeatureFlag == true ? null : mockFeatureFlagJson;
case 'getCachedContentCards':
return List<String>.generate(1, (index) => mockContentCardJson);
default:
Expand Down Expand Up @@ -991,25 +993,26 @@ void main() {
test('featureFlag convenience functions work', () async {
BrazePlugin _braze = new BrazePlugin();
final result = await _braze.getFeatureFlagByID("test");
expect(result.id, "test");
expect(result.enabled, true);
expect(result.properties.length, 4);
expect(result.getStringProperty("stringkey"), "stringValue");
expect(result.getBooleanProperty("booleankey"), true);
expect(result.getNumberProperty("number1key"), 4);
expect(result.getNumberProperty("number2key"), 5.1);
expect(result?.id, "test");
expect(result?.enabled, true);
expect(result?.properties.length, 4);
expect(result?.getStringProperty("stringkey"), "stringValue");
expect(result?.getBooleanProperty("booleankey"), true);
expect(result?.getNumberProperty("number1key"), 4);
expect(result?.getNumberProperty("number2key"), 5.1);
});

test('featureFlag convenience functions return null for non-existent keys',
() async {
BrazePlugin _braze = new BrazePlugin();
final result = await _braze.getFeatureFlagByID("test");
expect(result.getStringProperty("keyThatDoesntExist"), null);
expect(result.getBooleanProperty("keyThatDoesntExist"), null);
expect(result.getNumberProperty("keyThatDoesntExist"), null);
expect(result?.getStringProperty("keyThatDoesntExist"), null);
expect(result?.getBooleanProperty("keyThatDoesntExist"), null);
expect(result?.getNumberProperty("keyThatDoesntExist"), null);
});

test('should call getFeatureFlagByID', () async {
nullFeatureFlag = false;
BrazePlugin _braze = new BrazePlugin();
final result = await _braze.getFeatureFlagByID("test");
expect(log, <Matcher>[
Expand All @@ -1018,16 +1021,39 @@ void main() {
arguments: <String, dynamic>{'id': "test"},
),
]);
expect(result.id, "test");
expect(result.enabled, true);
expect(result.properties.length, 4);
expect(result.getStringProperty("stringkey"), "stringValue");
expect(result.getStringProperty("stringkeyThatDoesntExist"), null);
expect(result.getBooleanProperty("booleankey"), true);
expect(result.getBooleanProperty("booleanKeyThatDoesntExist"), null);
expect(result.getNumberProperty("number1key"), 4);
expect(result.getNumberProperty("number2key"), 5.1);
expect(result.getNumberProperty("numberKeyThatDoesntExist"), null);
expect(result?.id, "test");
expect(result?.enabled, true);
expect(result?.properties.length, 4);
expect(result?.getStringProperty("stringkey"), "stringValue");
expect(result?.getStringProperty("stringkeyThatDoesntExist"), null);
expect(result?.getBooleanProperty("booleankey"), true);
expect(result?.getBooleanProperty("booleanKeyThatDoesntExist"), null);
expect(result?.getNumberProperty("number1key"), 4);
expect(result?.getNumberProperty("number2key"), 5.1);
expect(result?.getNumberProperty("numberKeyThatDoesntExist"), null);
});

test('getFeatureFlagByID returns null for non-existent Feature Flag', () async {
nullFeatureFlag = true;
BrazePlugin _braze = new BrazePlugin();
final result = await _braze.getFeatureFlagByID("idThatDoesntExist");
expect(log, <Matcher>[
isMethodCall(
'getFeatureFlagByID',
arguments: <String, dynamic>{'id': "idThatDoesntExist"},
),
]);
expect(result, null);
expect(result?.id, null);
expect(result?.enabled, null);
expect(result?.properties.length, null);
expect(result?.getStringProperty("stringkey"), null);
expect(result?.getStringProperty("stringkeyThatDoesntExist"), null);
expect(result?.getBooleanProperty("booleankey"), null);
expect(result?.getBooleanProperty("booleanKeyThatDoesntExist"), null);
expect(result?.getNumberProperty("number1key"), null);
expect(result?.getNumberProperty("number2key"), null);
expect(result?.getNumberProperty("numberKeyThatDoesntExist"), null);
});

test('instantiate a BrazeInAppMessage object from JSON', () {
Expand Down

0 comments on commit 7ff4c8a

Please sign in to comment.