From 947d21b976ddf7c763f7c95e6a8d344b1990da6e Mon Sep 17 00:00:00 2001 From: charlesoj6205 Date: Tue, 28 Jul 2026 10:47:15 +0100 Subject: [PATCH 1/2] Update approov_service_flutter_httpclient to ^3.5.6 Align README, SHAPES-EXAMPLE and the example app on the current pub.dev release. The three files previously disagreed (^3.5.5 vs ^3.4.1); the example lockfile already resolved to 3.5.6. Co-Authored-By: Claude Opus 5 --- README.md | 2 +- SHAPES-EXAMPLE.md | 2 +- example/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3ca00ae..c5e7f8d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Note that the minimum OS requirement for iOS is 12 and for Android the minimum S The Approov integration is available via [`pub-dev`](https://pub.dev/packages/approov_service_flutter_httpclient) package. This allows inclusion into the project by simply specifying a dependency in the `pubspec.yaml` files for the app. In the `dependencies:` section of `pubspec.yaml` file add the following package reference: ```yaml -approov_service_flutter_httpclient: ^3.5.5 +approov_service_flutter_httpclient: ^3.5.6 ``` This package is actually an open source wrapper layer that allows you to easily use Approov with `Flutter`. This has a further dependency to the closed source [Android Approov SDK](https://github.com/approov/approov-android-sdk) and [iOS Approov SDK](https://github.com/approov/approov-ios-sdk) packages. Those are automatically added as dependencies for the platform specific targets. diff --git a/SHAPES-EXAMPLE.md b/SHAPES-EXAMPLE.md index aac7c85..7396c3d 100644 --- a/SHAPES-EXAMPLE.md +++ b/SHAPES-EXAMPLE.md @@ -100,7 +100,7 @@ and change them as shown: 1. Add the dependency for the `approov_service_flutter_httpclient` package ```yaml # *** UNCOMMENT THE SECTION BELOW FOR APPROOV *** - approov_service_flutter_httpclient: ^3.4.1 + approov_service_flutter_httpclient: ^3.5.6 ``` In the source file `quickstart-flutter-httpclient/example/lib/main.dart` find the two locations marked with a comment and change them: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 45db84a..750eb59 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: logger: ^2.0.2 # *** UNCOMMENT THE LINES BELOW FOR APPROOV *** - #approov_service_flutter_httpclient: ^3.4.1 + #approov_service_flutter_httpclient: ^3.5.6 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From 6b1aa3bf8e868636415826f45ad2cd486b0ad507 Mon Sep 17 00:00:00 2001 From: charlesoj6205 Date: Tue, 29 Sep 2026 12:45:43 +0100 Subject: [PATCH 2/2] Bump approov_service_flutter_httpclient to ^3.5.8 and await initialize In 3.5.8, a successful initialize() resets the service configuration. The example and docs called initialize() without await and then called addSubstitutionHeader(), so the reset deleted the header and the request went out with the placeholder API key. - Change the version to ^3.5.8 in example/pubspec.yaml, README.md and SHAPES-EXAMPLE.md. - Make main() async, call WidgetsFlutterBinding.ensureInitialized() and await initialize() in main() and in the isolate. - Show the await form in README.md and SHAPES-EXAMPLE.md. Tested on an Android 17 emulator with 3.5.8: without await, the server returned "invalid api key" and no substitution was attempted. With await, the substitution header stayed registered in the root isolate and in the background isolate. Refs approov/core-project-approov#647 Co-Authored-By: Claude Opus 5.5 --- README.md | 8 +++++--- SHAPES-EXAMPLE.md | 8 +++++--- example/lib/main.dart | 10 +++++++--- example/pubspec.yaml | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c5e7f8d..f83363d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Note that the minimum OS requirement for iOS is 12 and for Android the minimum S The Approov integration is available via [`pub-dev`](https://pub.dev/packages/approov_service_flutter_httpclient) package. This allows inclusion into the project by simply specifying a dependency in the `pubspec.yaml` files for the app. In the `dependencies:` section of `pubspec.yaml` file add the following package reference: ```yaml -approov_service_flutter_httpclient: ^3.5.6 +approov_service_flutter_httpclient: ^3.5.8 ``` This package is actually an open source wrapper layer that allows you to easily use Approov with `Flutter`. This has a further dependency to the closed source [Android Approov SDK](https://github.com/approov/approov-android-sdk) and [iOS Approov SDK](https://github.com/approov/approov-ios-sdk) packages. Those are automatically added as dependencies for the platform specific targets. @@ -55,9 +55,11 @@ You must initialize the `ApproovService` as early as possible in the initializat ```Dart import 'package:approov_service_flutter_httpclient/approov_service_flutter_httpclient.dart'; ... -ApproovService.initialize(''); +await ApproovService.initialize(''); ``` +The `initialize` method is asynchronous. Wait for it to complete (`await`) before you call any other `ApproovService` method, for example `addSubstitutionHeader`. A successful initialization resets the service configuration, so a configuration call made before it completes is lost. If initialization fails, `initialize` throws an `ApproovException`. + The `` is a custom string that configures your Approov account access. This will have been provided in your Approov onboarding email. You can then create an `ApproovClient` when needed as follows: @@ -120,7 +122,7 @@ Note that if you are using [Sentry](https://docs.sentry.io/platforms/flutter/) t Note that it is possible to also use Approov from background isolates as well as the root isolate. This relies on support for [platform plugins in isolates ](https://docs.flutter.dev/perf/isolates#using-platform-plugins-in-isolates) that was introduced in Flutter 3.7. Note that you must follow the instructions given there regarding a call to `BackgroundIsolateBinaryMessenger.ensureInitialized` or else Approov will not work in the isolate. -Since each isolate has a completely independent state you must call `ApproovService.initialize` in each isolate. You should do this as soon as possible after its creation. Make sure you provide exactly the same `config` string provided in the root and all other isolates, since the underlying Approov SDK is shared between them all and can only have a single active configuration at one time. Note that the Approov implementation in the root isolate may be marginally faster than those in other isolates since it is able to use the method callbacks from native code which are not available to background isolates. +Since each isolate has a completely independent state you must call `ApproovService.initialize` in each isolate and wait for it to complete (`await`). You should do this as soon as possible after its creation. Make sure you provide exactly the same `config` string provided in the root and all other isolates, since the underlying Approov SDK is shared between them all and can only have a single active configuration at one time. Note that the Approov implementation in the root isolate may be marginally faster than those in other isolates since it is able to use the method callbacks from native code which are not available to background isolates. ## CHECKING IT WORKS Initially you won't have set which API domains to protect, so the interceptor will not add anything. It will have called Approov though and made contact with the Approov cloud service. You will see logging from Approov saying `UNKNOWN_URL`. diff --git a/SHAPES-EXAMPLE.md b/SHAPES-EXAMPLE.md index 7396c3d..27db053 100644 --- a/SHAPES-EXAMPLE.md +++ b/SHAPES-EXAMPLE.md @@ -100,7 +100,7 @@ and change them as shown: 1. Add the dependency for the `approov_service_flutter_httpclient` package ```yaml # *** UNCOMMENT THE SECTION BELOW FOR APPROOV *** - approov_service_flutter_httpclient: ^3.5.6 + approov_service_flutter_httpclient: ^3.5.8 ``` In the source file `quickstart-flutter-httpclient/example/lib/main.dart` find the two locations marked with a comment and change them: @@ -116,9 +116,11 @@ import 'package:approov_service_flutter_httpclient/approov_service_flutter_httpc ```Dart // *** UNCOMMENT THE LINE BELOW FOR APPROOV *** -ApproovService.initialize(''); +await ApproovService.initialize(''); ``` +The `main` function is already `async`. Keep the `await`: a successful initialization resets the service configuration, so the `addSubstitutionHeader` call that follows it is lost if it runs before initialization completes. + The `` is a custom string that configures your Approov account access. This will have been provided in your Approov onboarding email. 3. Create an Approov Client: @@ -138,7 +140,7 @@ final http.Client _client = ApproovClient(); //HttpClient client = HttpClient(); // *** UNCOMMENT THE TWO LINES BELOW FOR APPROOV *** -ApproovService.initialize(''); +await ApproovService.initialize(''); HttpClient client = ApproovHttpClient(); ``` diff --git a/example/lib/main.dart b/example/lib/main.dart index 92f16a2..a0a11f7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,9 +39,13 @@ const String SHAPE_URL = "https://shapes.approov.io/$API_VERSION/shapes"; // using SECRETS PROTECTION const API_KEY = "yXClypapWNHIifHUWmBIyPFAm"; -void main() { +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + // *** UNCOMMENT THE LINE BELOW FOR APPROOV *** - //ApproovService.initialize(''); + // Wait for initialization to complete before any other ApproovService call. A successful + // initialization resets the service configuration, so a call made before it completes is lost. + //await ApproovService.initialize(''); // *** UNCOMMENT THE LINE BELOW FOR APPROOV USING SECRETS PROTECTION *** //ApproovService.addSubstitutionHeader("api-key", null); @@ -158,7 +162,7 @@ class _ShapesState extends State { HttpClient client = HttpClient(); // *** UNCOMMENT THE TWO LINES BELOW FOR APPROOV *** - //ApproovService.initialize(''); + //await ApproovService.initialize(''); //HttpClient client = ApproovHttpClient(); // *** UNCOMMENT THE LINE BELOW FOR APPROOV USING SECRETS PROTECTION *** diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 750eb59..db8f1bb 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: logger: ^2.0.2 # *** UNCOMMENT THE LINES BELOW FOR APPROOV *** - #approov_service_flutter_httpclient: ^3.5.6 + #approov_service_flutter_httpclient: ^3.5.8 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.