Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 32 additions & 28 deletions packages/cloud_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,99 @@
## 0.4.0+3
Comment thread
DavoBR marked this conversation as resolved.

- Allow use cloud functions locally.
Comment thread
DavoBR marked this conversation as resolved.
Outdated

## 0.4.0+2

* Automatically use version from pubspec.yaml when reporting usage to Firebase.
- Automatically use version from pubspec.yaml when reporting usage to Firebase.
Comment thread
DavoBR marked this conversation as resolved.
Outdated

## 0.4.0+1

* Remove reference to unused header file.
- Remove reference to unused header file.

## 0.4.0

* Removed unused `parameters` param from `getHttpsCallable`.
- Removed unused `parameters` param from `getHttpsCallable`.

## 0.3.0+1

* Update iOS dependencies to latest.
- Update iOS dependencies to latest.

## 0.3.0

* Update Android dependencies to latest.
- Update Android dependencies to latest.

## 0.2.0+1

* Removed flaky timeout test.
- Removed flaky timeout test.

## 0.2.0

* **Breaking change**. Updated Dart API to replace `call` with `getHttpsCallable`.
* Added support for timeouts.
* Additional integration testing.
- **Breaking change**. Updated Dart API to replace `call` with `getHttpsCallable`.
- Added support for timeouts.
- Additional integration testing.

## 0.1.2+1

* Added a driver test.
- Added a driver test.

## 0.1.2

* Specifying a version for Cloud Functions CocoaPod dependency to prevent build errors on iOS.
* Fix on iOS when using a null region.
* Upgrade the firebase_core dependency of the example app.
- Specifying a version for Cloud Functions CocoaPod dependency to prevent build errors on iOS.
- Fix on iOS when using a null region.
- Upgrade the firebase_core dependency of the example app.

## 0.1.1+1

* Log messages about automatic configuration of the default app are now less confusing.
- Log messages about automatic configuration of the default app are now less confusing.

## 0.1.1

* Support for regions and multiple apps
- Support for regions and multiple apps

## 0.1.0+1

* Log a more detailed warning at build time about the previous AndroidX
- Log a more detailed warning at build time about the previous AndroidX
migration.

## 0.1.0

* **Breaking change**. Migrate from the deprecated original Android Support
- **Breaking change**. Migrate from the deprecated original Android Support
Library to AndroidX. This shouldn't result in any functional changes, but it
requires any Android apps using this plugin to [also
migrate](https://developer.android.com/jetpack/androidx/migrate) if they're
using the original support library.

## 0.0.5

* Set iOS deployment target to 8.0 (minimum supported by both Firebase SDKs and Flutter), fixes compilation errors.
* Fixes null pointer error when callable function fails with exception (iOS).
- Set iOS deployment target to 8.0 (minimum supported by both Firebase SDKs and Flutter), fixes compilation errors.
- Fixes null pointer error when callable function fails with exception (iOS).

## 0.0.4+1

* Bump Android dependencies to latest.
- Bump Android dependencies to latest.

## 0.0.4

* Fixed podspec to use static_framework
- Fixed podspec to use static_framework

## 0.0.3

* Added missing dependency on meta package.
- Added missing dependency on meta package.

## 0.0.2

* Bump Android and Firebase dependency versions.
- Bump Android and Firebase dependency versions.

## 0.0.1

* The Cloud Functions for Firebase client SDKs let you call functions
- The Cloud Functions for Firebase client SDKs let you call functions
directly from a Firebase app. This plugin exposes this ability to
Flutter apps.

[Callable functions](https://firebase.google.com/docs/functions/callable)
are similar to other HTTP functions, with these additional features:

- With callables, Firebase Authentication and FCM tokens are
automatically included in requests.
- The functions.https.onCall trigger automatically deserializes
the request body and validates auth tokens.
- With callables, Firebase Authentication and FCM tokens are
automatically included in requests.
- The functions.https.onCall trigger automatically deserializes
the request body and validates auth tokens.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ public void onMethodCall(MethodCall call, final Result result) {
String appName = call.argument("app");
FirebaseApp app = FirebaseApp.getInstance(appName);
String region = call.argument("region");
String origin = call.argument("origin");
FirebaseFunctions functions;
if (region != null) {
functions = FirebaseFunctions.getInstance(app, region);
} else {
functions = FirebaseFunctions.getInstance(app);
}
if (origin != null) {
functions.useFunctionsEmulator(origin);
}
HttpsCallableReference httpsCallableReference = functions.getHttpsCallable(functionName);
Number timeoutMilliseconds = call.argument("timeoutMilliseconds");
if (timeoutMilliseconds != null) {
Expand Down
4 changes: 4 additions & 0 deletions packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
NSObject *parameters = call.arguments[@"parameters"];
NSString *appName = call.arguments[@"app"];
NSString *region = call.arguments[@"region"];
NSString *origin = call.arguments[@"origin"];
NSNumber *timeoutMicroseconds = call.arguments[@"timeoutMicroseconds"];
FIRApp *app = [FIRApp appNamed:appName];
FIRFunctions *functions;
Expand All @@ -52,6 +53,9 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
} else {
functions = [FIRFunctions functionsForApp:app];
}
if (origin != nil && origin != (id)[NSNull null]) {
[functions useFunctionsEmulatorOrigin:origin];
}
FIRHTTPSCallable *function = [functions HTTPSCallableWithName:functionName];
if (timeoutMicroseconds != nil && timeoutMicroseconds != [NSNull null]) {
[function setTimeoutInterval:(NSTimeInterval)timeoutMicroseconds.doubleValue / 1000000];
Expand Down
15 changes: 13 additions & 2 deletions packages/cloud_functions/lib/src/cloud_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class CloudFunctionsException implements Exception {
///
/// You can get an instance by calling [CloudFunctions.instance].
class CloudFunctions {
CloudFunctions({FirebaseApp app, String region})
CloudFunctions({FirebaseApp app, String region, String origin})
: _app = app ?? FirebaseApp.instance,
_region = region;
_region = region,
_origin = origin;

@visibleForTesting
static const MethodChannel channel = MethodChannel('cloud_functions');
Expand All @@ -31,6 +32,8 @@ class CloudFunctions {

final String _region;

String _origin;

/// Gets an instance of a Callable HTTPS trigger in Cloud Functions.
///
/// Can then be executed by calling `call()` on it.
Expand All @@ -39,4 +42,12 @@ class CloudFunctions {
HttpsCallable getHttpsCallable({@required String functionName}) {
return HttpsCallable._(this, functionName);
}

/// Changes this instance to point to a Cloud Functions emulator running locally.
///
/// @param origin The origin of the local emulator, such as "//10.0.2.2:5005".
CloudFunctions useEmulatorFunctions({@required String origin}) {
Comment thread
DavoBR marked this conversation as resolved.
Outdated
_origin = origin;
return this;
}
}
1 change: 1 addition & 0 deletions packages/cloud_functions/lib/src/https_callable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HttpsCallable {
.invokeMethod<dynamic>('CloudFunctions#call', <String, dynamic>{
'app': _cloudFunctions._app.name,
'region': _cloudFunctions._region,
'origin': _cloudFunctions._origin,
'timeoutMicroseconds': timeout?.inMicroseconds,
'functionName': _functionName,
'parameters': parameters,
Expand Down
6 changes: 3 additions & 3 deletions packages/cloud_functions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cloud_functions
description: Flutter plugin for Cloud Functions.
version: 0.4.0+2
version: 0.4.0+3
Comment thread
DavoBR marked this conversation as resolved.
Outdated
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions

Expand All @@ -23,5 +23,5 @@ dev_dependencies:
test: any

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
flutter: ">=0.2.4 <2.0.0"
sdk: '>=2.0.0-dev.28.0 <3.0.0'
flutter: '>=0.2.4 <2.0.0'
17 changes: 17 additions & 0 deletions packages/cloud_functions/test/cloud_functions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ void main() {
await callable.call(<String, dynamic>{
'quux': 'quuz',
});
await CloudFunctions.instance
.useEmulatorFunctions(origin: 'http://localhost:5001')
Comment thread
DavoBR marked this conversation as resolved.
Outdated
Comment thread
DavoBR marked this conversation as resolved.
Outdated
.getHttpsCallable(functionName: 'bez')
.call();
expect(
log,
<Matcher>[
Expand All @@ -46,6 +50,7 @@ void main() {
arguments: <String, dynamic>{
'app': '[DEFAULT]',
'region': null,
'origin': null,
'functionName': 'baz',
'timeoutMicroseconds': null,
'parameters': null,
Expand All @@ -56,11 +61,23 @@ void main() {
arguments: <String, dynamic>{
'app': '1337',
'region': 'space',
'origin': null,
'functionName': 'qux',
'timeoutMicroseconds': (const Duration(days: 300)).inMicroseconds,
'parameters': <String, dynamic>{'quux': 'quuz'},
},
),
isMethodCall(
'CloudFunctions#call',
arguments: <String, dynamic>{
'app': '[DEFAULT]',
'region': null,
'origin': 'http://localhost:5001',
'functionName': 'bez',
'timeoutMicroseconds': null,
'parameters': null,
},
),
],
);
});
Expand Down