Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Audrius Karosevicius <audrius.karosevicius@gmail.com>
Lukasz Piliszczuk <lukasz@intheloup.io>
SoundReply Solutions GmbH <ch@soundreply.com>
Michel Feinstein <michel@feinstein.com.br>
Tobias Löfstrand <tobias@leafnode.se>
Tobias Löfstrand <tobias@leafnode.se>
Stephen Beitzel <sbeitzel@pobox.com>
6 changes: 6 additions & 0 deletions packages/cloud_functions/cloud_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.4.1+7

* Update to use the platform interface to execute calls.
* Fix timeout for Android (which had been ignoring explicit timeouts due to unit mismatch).
* Update repository location based on platform interface refactoring.

## 0.4.1+6

* Fix analysis failures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public void onMethodCall(MethodCall call, final Result result) {
functions.useFunctionsEmulator(origin);
}
HttpsCallableReference httpsCallableReference = functions.getHttpsCallable(functionName);
Number timeoutMilliseconds = call.argument("timeoutMilliseconds");
Comment thread
sbeitzel marked this conversation as resolved.
if (timeoutMilliseconds != null) {
httpsCallableReference.setTimeout(timeoutMilliseconds.longValue(), TimeUnit.MILLISECONDS);
Number timeoutMicroseconds = call.argument("timeoutMicroseconds");
if (timeoutMicroseconds != null) {
httpsCallableReference.setTimeout(timeoutMicroseconds.longValue(), TimeUnit.MICROSECONDS);
}
httpsCallableReference
.call(parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
library cloud_functions;

import 'dart:async';

import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class CloudFunctions {
: _app = app ?? FirebaseApp.instance,
_region = region;

@visibleForTesting
static const MethodChannel channel = MethodChannel('cloud_functions');

static CloudFunctions _instance = CloudFunctions();

static CloudFunctions get instance => _instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@ class HttpsCallable {
/// automatically includes a Firebase Instance ID token to identify the app
/// instance. If a user is logged in with Firebase Auth, an auth ID token for
/// the user is also automatically included.
Future<HttpsCallableResult> call([dynamic parameters]) async {
Future<HttpsCallableResult> call([dynamic parameters]) {
try {
final MethodChannel channel = CloudFunctions.channel;
final dynamic response = await channel
.invokeMethod<dynamic>('CloudFunctions#call', <String, dynamic>{
'app': _cloudFunctions._app.name,
'region': _cloudFunctions._region,
'origin': _cloudFunctions._origin,
'timeoutMicroseconds': timeout?.inMicroseconds,
'functionName': _functionName,
'parameters': parameters,
});
return HttpsCallableResult._(response);
return CloudFunctionsPlatform.instance
Comment thread
sbeitzel marked this conversation as resolved.
.callCloudFunction(
appName: _cloudFunctions._app.name,
region: _cloudFunctions._region,
origin: _cloudFunctions._origin,
timeout: timeout,
functionName: _functionName,
parameters: parameters,
)
.then((response) => HttpsCallableResult._(response));
} on PlatformException catch (e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this catch remain, if an error does not fall into it?

if (e.code == 'functionsError') {
final String code = e.details['code'];
Expand Down
5 changes: 3 additions & 2 deletions packages/cloud_functions/cloud_functions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cloud_functions
description: Flutter plugin for Cloud Functions.
version: 0.4.1+6
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions
version: 0.4.1+7
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions/cloud_functions

flutter:
plugin:
Expand All @@ -17,6 +17,7 @@ dependencies:
flutter:
sdk: flutter
firebase_core: ^0.4.0
cloud_functions_platform_interface: ^1.0.0

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:cloud_functions/cloud_functions.dart';
import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -14,7 +15,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];

setUp(() async {
CloudFunctions.channel
MethodChannelCloudFunctions.channel
.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
switch (methodCall.method) {
Expand Down