From e71fe0d95c06bdc89d7cbfac7f75b7c17591cb24 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 12:31:51 +0100 Subject: [PATCH 01/21] add region variable for function call and use this for android --- packages/cloud_functions/example/lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cloud_functions/example/lib/main.dart b/packages/cloud_functions/example/lib/main.dart index 205d45d2ffe6..0ac957c98b9c 100644 --- a/packages/cloud_functions/example/lib/main.dart +++ b/packages/cloud_functions/example/lib/main.dart @@ -35,6 +35,7 @@ class _MyAppState extends State { try { final dynamic resp = await CloudFunctions.instance.call( functionName: 'repeat', + region: 'us-central1', parameters: { 'message': 'hello world!', 'count': _responseCount, From 8cc5a6bad3441f5c6d69e5d420ffd2ecfadf6fb7 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 13:08:56 +0100 Subject: [PATCH 02/21] first try to implement region support for ios --- .../cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java | 3 ++- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 4 +++- packages/cloud_functions/lib/cloud_functions.dart | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java b/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java index 3de5a3d6ee0e..4fbb02533aab 100644 --- a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java +++ b/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java @@ -32,8 +32,9 @@ public void onMethodCall(MethodCall call, final Result result) { switch (call.method) { case "CloudFunctions#call": String functionName = call.argument("functionName"); + String region = call.argument("region"); HttpsCallableReference httpsCallableReference = - FirebaseFunctions.getInstance().getHttpsCallable(functionName); + FirebaseFunctions.getInstance(region).getHttpsCallable(functionName); Map parameters = call.argument("parameters"); httpsCallableReference .call(parameters) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 701c5efb3466..a3ff6fd25730 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -34,8 +34,10 @@ - (instancetype)init { - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { if ([@"CloudFunctions#call" isEqualToString:call.method]) { NSString *functionName = call.arguments[@"functionName"]; + NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; - [[FIRFunctions functions] + [[FIRFunctions functionsForRegion] + region:region callFunction:functionName withObject:parameters completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index f280a55a13fe..51ac9c49bfae 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -31,11 +31,11 @@ class CloudFunctions { /// @param functionName The name of the callable function being triggered. /// @param parameters Parameters to be passed to the callable function. Future call( - {@required String functionName, Map parameters}) async { + {@required String functionName, String region, Map parameters}) async { try { - final dynamic response = - await channel.invokeMethod('CloudFunctions#call', { + final dynamic response = await channel.invokeMethod('CloudFunctions#call', { 'functionName': functionName, + 'region': region, 'parameters': parameters, }); return response; From c1993e61afd2d734dfb742189ebc55cf26bdc353 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 15:40:15 +0100 Subject: [PATCH 03/21] added region support for ios --- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index a3ff6fd25730..e980f53e3e1f 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -36,9 +36,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *functionName = call.arguments[@"functionName"]; NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; - [[FIRFunctions functionsForRegion] - region:region - callFunction:functionName + [[[FIRFunctions functionsForRegion:region]HTTPSCallableWithName:functionName] withObject:parameters completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { if (error) { From 285e39bd0b242366bc1409204f2a0b07c384636e Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:23:04 +0100 Subject: [PATCH 04/21] use us-central as default when no region is given --- packages/cloud_functions/example/lib/main.dart | 1 - .../cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 2 +- packages/cloud_functions/lib/cloud_functions.dart | 9 ++++++--- packages/cloud_functions/pubspec.yaml | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/cloud_functions/example/lib/main.dart b/packages/cloud_functions/example/lib/main.dart index 0ac957c98b9c..205d45d2ffe6 100644 --- a/packages/cloud_functions/example/lib/main.dart +++ b/packages/cloud_functions/example/lib/main.dart @@ -35,7 +35,6 @@ class _MyAppState extends State { try { final dynamic resp = await CloudFunctions.instance.call( functionName: 'repeat', - region: 'us-central1', parameters: { 'message': 'hello world!', 'count': _responseCount, diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index e980f53e3e1f..d6c5e8a612c2 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -36,7 +36,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *functionName = call.arguments[@"functionName"]; NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; - [[[FIRFunctions functionsForRegion:region]HTTPSCallableWithName:functionName] + [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] withObject:parameters completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { if (error) { diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index 51ac9c49bfae..d2fee45c9b17 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -31,11 +31,14 @@ class CloudFunctions { /// @param functionName The name of the callable function being triggered. /// @param parameters Parameters to be passed to the callable function. Future call( - {@required String functionName, String region, Map parameters}) async { + {@required String functionName, + String region, Map parameters}) async { try { - final dynamic response = await channel.invokeMethod('CloudFunctions#call', { + final dynamic response = + await channel.invokeMethod('CloudFunctions#call', { 'functionName': functionName, - 'region': region, + 'region': region ?? "us-central1", 'parameters': parameters, }); return response; diff --git a/packages/cloud_functions/pubspec.yaml b/packages/cloud_functions/pubspec.yaml index 145ae0707d37..c316ee79306e 100644 --- a/packages/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/pubspec.yaml @@ -18,6 +18,7 @@ dev_dependencies: flutter_test: sdk: flutter firebase_core: ^0.2.5+1 + flutter_plugin_tools: ^0.0.14+1 environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" From 888ad3bf23df40971d31974c387fe5ee30f208fc Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:30:46 +0100 Subject: [PATCH 05/21] remove flutter plugin tool --- packages/cloud_functions/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cloud_functions/pubspec.yaml b/packages/cloud_functions/pubspec.yaml index c316ee79306e..145ae0707d37 100644 --- a/packages/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/pubspec.yaml @@ -18,7 +18,6 @@ dev_dependencies: flutter_test: sdk: flutter firebase_core: ^0.2.5+1 - flutter_plugin_tools: ^0.0.14+1 environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" From 49ec0dc5cc8260c8b84cf7289237e18f049e7380 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:35:12 +0100 Subject: [PATCH 06/21] added test case for given region, and adapted old ones for empty region --- .../cloud_functions/test/cloud_functions_test.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/test/cloud_functions_test.dart index 51bf3f0a1edc..b7bfe0b7aac6 100644 --- a/packages/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/test/cloud_functions_test.dart @@ -32,6 +32,7 @@ void main() { .call(functionName: 'qux', parameters: { 'quux': 'quuz', }); + await CloudFunctions.instance.call(functionName: 'buz', region:'us-east1') expect( log, [ @@ -39,6 +40,7 @@ void main() { 'CloudFunctions#call', arguments: { 'functionName': 'baz', + 'region': 'us-central1' 'parameters': null, }, ), @@ -46,6 +48,17 @@ void main() { 'CloudFunctions#call', arguments: { 'functionName': 'qux', + 'region': 'us-central1' + 'parameters': { + 'quux': 'quuz', + }, + }, + ), + isMethodCall( + 'CloudFunctions#call', + arguments: { + 'functionName': 'qux', + 'region': 'us-east1' 'parameters': { 'quux': 'quuz', }, From 206983e43e84a5bf0165ea4f201959cb9ab3e5f9 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:41:38 +0100 Subject: [PATCH 07/21] added missing bracket --- packages/cloud_functions/test/cloud_functions_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/test/cloud_functions_test.dart index b7bfe0b7aac6..9af411e5ccc5 100644 --- a/packages/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/test/cloud_functions_test.dart @@ -32,7 +32,7 @@ void main() { .call(functionName: 'qux', parameters: { 'quux': 'quuz', }); - await CloudFunctions.instance.call(functionName: 'buz', region:'us-east1') + await CloudFunctions.instance.call(functionName: 'buz', region:'us-east1'); expect( log, [ From 018faf334814964a74e615d3e9984884858fdde7 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:43:14 +0100 Subject: [PATCH 08/21] add missing commas --- packages/cloud_functions/test/cloud_functions_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/test/cloud_functions_test.dart index 9af411e5ccc5..994d4869cd6a 100644 --- a/packages/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/test/cloud_functions_test.dart @@ -32,7 +32,7 @@ void main() { .call(functionName: 'qux', parameters: { 'quux': 'quuz', }); - await CloudFunctions.instance.call(functionName: 'buz', region:'us-east1'); + await CloudFunctions.instance.call(functionName: 'buz', region: 'us-east1'); expect( log, [ @@ -40,7 +40,7 @@ void main() { 'CloudFunctions#call', arguments: { 'functionName': 'baz', - 'region': 'us-central1' + 'region': 'us-central1', 'parameters': null, }, ), @@ -48,7 +48,7 @@ void main() { 'CloudFunctions#call', arguments: { 'functionName': 'qux', - 'region': 'us-central1' + 'region': 'us-central1', 'parameters': { 'quux': 'quuz', }, @@ -58,7 +58,7 @@ void main() { 'CloudFunctions#call', arguments: { 'functionName': 'qux', - 'region': 'us-east1' + 'region': 'us-east1', 'parameters': { 'quux': 'quuz', }, From de4558047a384bf39a112e2af8a315daeffc81ef Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:47:02 +0100 Subject: [PATCH 09/21] add param description for region --- packages/cloud_functions/lib/cloud_functions.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index d2fee45c9b17..f1ee4a0ae4f1 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -29,6 +29,7 @@ class CloudFunctions { /// Executes this Callable HTTPS trigger asynchronously. /// /// @param functionName The name of the callable function being triggered. + /// @param region The region where the callable function being triggered. Default is us-central1. /// @param parameters Parameters to be passed to the callable function. Future call( {@required String functionName, From 6e0339cee156aed5758877d5baa08de8f7d8b01c Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:49:44 +0100 Subject: [PATCH 10/21] solved failing test case --- packages/cloud_functions/test/cloud_functions_test.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/test/cloud_functions_test.dart index 994d4869cd6a..2da044725391 100644 --- a/packages/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/test/cloud_functions_test.dart @@ -57,11 +57,9 @@ void main() { isMethodCall( 'CloudFunctions#call', arguments: { - 'functionName': 'qux', + 'functionName': 'buz', 'region': 'us-east1', - 'parameters': { - 'quux': 'quuz', - }, + 'parameters': null, }, ), ], From 92466c2aefa2ff8c03df556a3199ef2463199905 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 18:59:47 +0100 Subject: [PATCH 11/21] adjust format --- .../ios/Classes/CloudFunctionsPlugin.m | 49 ++++++++++--------- .../cloud_functions/lib/cloud_functions.dart | 4 +- .../test/cloud_functions_test.dart | 3 +- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index d6c5e8a612c2..9b95c32ad242 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -37,34 +37,35 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] - withObject:parameters - completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { - if (error) { - FlutterError *flutterError; - if (error.domain == FIRFunctionsErrorDomain) { - NSDictionary *details = [NSMutableDictionary dictionary]; - [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; - if (error.localizedDescription != nil) { - [details setValue:error.localizedDescription forKey:@"message"]; - } - if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - - flutterError = - [FlutterError errorWithCode:@"functionsError" - message:@"Firebase function failed with exception." - details:details]; - } else { - flutterError = [FlutterError errorWithCode:nil - message:error.localizedDescription - details:nil]; + withObject:parameters + completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { + if (error) { + FlutterError *flutterError; + if (error.domain == FIRFunctionsErrorDomain) { + NSDictionary *details = [NSMutableDictionary dictionary]; + [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; + if (error.localizedDescription != nil) { + [details setValue:error.localizedDescription forKey:@"message"]; } + if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + } result(flutterError); - } else { + flutterError = [FlutterError errorWithCode:@"functionsError" + message:@"Firebase function failed with exception." + details:details]; + } else { result(callableResult.data); - } + flutterError = [FlutterError errorWithCode:nil + message:error.localizedDescription + details:nil]; + } }]; + result(flutterError); + } else { + result(callableResult.data); + } + }]; } else { result(FlutterMethodNotImplemented); } diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index f1ee4a0ae4f1..e33c7015b7a2 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -33,8 +33,8 @@ class CloudFunctions { /// @param parameters Parameters to be passed to the callable function. Future call( {@required String functionName, - String region, Map parameters}) async { + String region, + Map parameters}) async { try { final dynamic response = await channel.invokeMethod('CloudFunctions#call', { diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/test/cloud_functions_test.dart index 2da044725391..f0b49bbccad9 100644 --- a/packages/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/test/cloud_functions_test.dart @@ -32,7 +32,8 @@ void main() { .call(functionName: 'qux', parameters: { 'quux': 'quuz', }); - await CloudFunctions.instance.call(functionName: 'buz', region: 'us-east1'); + await CloudFunctions.instance + .call(functionName: 'buz', region: 'us-east1'); expect( log, [ From ec83d6136aaa2fcfce0482bcc52bf8f7b95b8b45 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 19:06:34 +0100 Subject: [PATCH 12/21] remove duplicated code --- .../cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 9b95c32ad242..a1756eaec126 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -49,18 +49,15 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - result(flutterError); + } flutterError = [FlutterError errorWithCode:@"functionsError" message:@"Firebase function failed with exception." details:details]; } else { - result(callableResult.data); - flutterError = [FlutterError errorWithCode:nil + flutterError = [FlutterError errorWithCode:nil message:error.localizedDescription details:nil]; } - }]; result(flutterError); } else { result(callableResult.data); From a0a632e56222d2ed553323c42e90dc38e9be5021 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 19:17:54 +0100 Subject: [PATCH 13/21] more code formation --- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index a1756eaec126..820180291814 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -53,11 +53,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result flutterError = [FlutterError errorWithCode:@"functionsError" message:@"Firebase function failed with exception." details:details]; - } else { - flutterError = [FlutterError errorWithCode:nil + } else { + flutterError = [FlutterError errorWithCode:nil message:error.localizedDescription details:nil]; - } + } result(flutterError); } else { result(callableResult.data); From 95f2a973a90cd4c7f743dfe7843d270e1bac8cc0 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 20:40:04 +0100 Subject: [PATCH 14/21] use correct parameter call --- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 820180291814..eb4f32b1478d 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -37,7 +37,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] - withObject:parameters + callWithObject:parameters completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { if (error) { FlutterError *flutterError; From 44358ed263530f42c1d16cae386925692f47e7b5 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 20:49:25 +0100 Subject: [PATCH 15/21] code format --- .../ios/Classes/CloudFunctionsPlugin.m | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index eb4f32b1478d..72327c4d19fe 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -38,31 +38,31 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSObject *parameters = call.arguments[@"parameters"]; [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] callWithObject:parameters - completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { - if (error) { - FlutterError *flutterError; - if (error.domain == FIRFunctionsErrorDomain) { - NSDictionary *details = [NSMutableDictionary dictionary]; - [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; - if (error.localizedDescription != nil) { - [details setValue:error.localizedDescription forKey:@"message"]; - } - if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - flutterError = [FlutterError errorWithCode:@"functionsError" + completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { + if (error) { + FlutterError *flutterError; + if (error.domain == FIRFunctionsErrorDomain) { + NSDictionary *details = [NSMutableDictionary dictionary]; + [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; + if (error.localizedDescription != nil) { + [details setValue:error.localizedDescription forKey:@"message"]; + } + if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + } + flutterError = [FlutterError errorWithCode:@"functionsError" message:@"Firebase function failed with exception." details:details]; - } else { - flutterError = [FlutterError errorWithCode:nil + } else { + flutterError = [FlutterError errorWithCode:nil message:error.localizedDescription details:nil]; + } + result(flutterError); + } else { + result(callableResult.data); } - result(flutterError); - } else { - result(callableResult.data); - } - }]; + }]; } else { result(FlutterMethodNotImplemented); } From 64fd4052e34cfc117645f45523ad102da7bbb7ac Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 20:53:09 +0100 Subject: [PATCH 16/21] code format --- .../ios/Classes/CloudFunctionsPlugin.m | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 72327c4d19fe..e41fd3a0499c 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -37,32 +37,32 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] - callWithObject:parameters - completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { - if (error) { - FlutterError *flutterError; - if (error.domain == FIRFunctionsErrorDomain) { - NSDictionary *details = [NSMutableDictionary dictionary]; - [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; - if (error.localizedDescription != nil) { - [details setValue:error.localizedDescription forKey:@"message"]; - } - if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - flutterError = [FlutterError errorWithCode:@"functionsError" - message:@"Firebase function failed with exception." - details:details]; - } else { - flutterError = [FlutterError errorWithCode:nil - message:error.localizedDescription - details:nil]; + callWithObject:parameters + completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { + if (error) { + FlutterError *flutterError; + if (error.domain == FIRFunctionsErrorDomain) { + NSDictionary *details = [NSMutableDictionary dictionary]; + [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; + if (error.localizedDescription != nil) { + [details setValue:error.localizedDescription forKey:@"message"]; } - result(flutterError); + if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + } + flutterError = [FlutterError errorWithCode:@"functionsError" + message:@"Firebase function failed with exception." + details:details]; } else { - result(callableResult.data); + flutterError = [FlutterError errorWithCode:nil + message:error.localizedDescription + details:nil]; } - }]; + result(flutterError); + } else { + result(callableResult.data); + } + }]; } else { result(FlutterMethodNotImplemented); } From 54d1c98629ca0905e7b22be1a4f1253f78822192 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 20:59:36 +0100 Subject: [PATCH 17/21] code format again --- .../ios/Classes/CloudFunctionsPlugin.m | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index e41fd3a0499c..26987a1e1e99 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -37,32 +37,32 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *region = call.arguments[@"region"]; NSObject *parameters = call.arguments[@"parameters"]; [[[FIRFunctions functionsForRegion:region] HTTPSCallableWithName:functionName] - callWithObject:parameters - completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { - if (error) { - FlutterError *flutterError; - if (error.domain == FIRFunctionsErrorDomain) { - NSDictionary *details = [NSMutableDictionary dictionary]; - [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; - if (error.localizedDescription != nil) { - [details setValue:error.localizedDescription forKey:@"message"]; + callWithObject:parameters + completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) { + if (error) { + FlutterError *flutterError; + if (error.domain == FIRFunctionsErrorDomain) { + NSDictionary *details = [NSMutableDictionary dictionary]; + [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; + if (error.localizedDescription != nil) { + [details setValue:error.localizedDescription forKey:@"message"]; + } + if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + } + flutterError = [FlutterError errorWithCode:@"functionsError" + message:@"Firebase function failed with exception." + details:details]; + } else { + flutterError = [FlutterError errorWithCode:nil + message:error.localizedDescription + details:nil]; + } + result(flutterError); + } else { + result(callableResult.data); } - if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - flutterError = [FlutterError errorWithCode:@"functionsError" - message:@"Firebase function failed with exception." - details:details]; - } else { - flutterError = [FlutterError errorWithCode:nil - message:error.localizedDescription - details:nil]; - } - result(flutterError); - } else { - result(callableResult.data); - } - }]; + }]; } else { result(FlutterMethodNotImplemented); } From 31e5b089db841a337654dc9d634117a7b7244429 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 21:04:46 +0100 Subject: [PATCH 18/21] code format again again --- .../ios/Classes/CloudFunctionsPlugin.m | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 26987a1e1e99..18b9784afd82 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -44,19 +44,20 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result if (error.domain == FIRFunctionsErrorDomain) { NSDictionary *details = [NSMutableDictionary dictionary]; [details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"]; - if (error.localizedDescription != nil) { - [details setValue:error.localizedDescription forKey:@"message"]; - } - if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; - } - flutterError = [FlutterError errorWithCode:@"functionsError" - message:@"Firebase function failed with exception." - details:details]; + if (error.localizedDescription != nil) { + [details setValue:error.localizedDescription forKey:@"message"]; + } + if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + } + flutterError = + [FlutterError errorWithCode:@"functionsError" + message:@"Firebase function failed with exception." + details:details]; } else { flutterError = [FlutterError errorWithCode:nil - message:error.localizedDescription - details:nil]; + message:error.localizedDescription + details:nil]; } result(flutterError); } else { From 16db30b30ae06f9741eb19c74eb08d282d43a5e4 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Wed, 9 Jan 2019 21:10:02 +0100 Subject: [PATCH 19/21] code format one last time? --- .../cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 18b9784afd82..1aa5831682e5 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -48,7 +48,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result [details setValue:error.localizedDescription forKey:@"message"]; } if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) { - [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"]; + [details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] + forKey:@"details"]; } flutterError = [FlutterError errorWithCode:@"functionsError" @@ -56,8 +57,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result details:details]; } else { flutterError = [FlutterError errorWithCode:nil - message:error.localizedDescription - details:nil]; + message:error.localizedDescription + details:nil]; } result(flutterError); } else { From e0bac205c3899e35376373b2d1a84404cc9e474d Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Fri, 8 Feb 2019 13:00:30 +0100 Subject: [PATCH 20/21] use default value for region parameter --- packages/cloud_functions/lib/cloud_functions.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index ce0adb3f5449..433f4e03fe22 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -33,7 +33,7 @@ class CloudFunctions { /// @param parameters Parameters to be passed to the callable function. Future call( {@required String functionName, - String region, + String region = 'us-central1', Map parameters}) async { try { final dynamic response = @@ -42,7 +42,7 @@ class CloudFunctions { // ignore: strong_mode_implicit_dynamic_method await channel.invokeMethod('CloudFunctions#call', { 'functionName': functionName, - 'region': region ?? "us-central1", + 'region': region, 'parameters': parameters, }); return response; From 193bc5295d47341f02f547704577ece408fe4823 Mon Sep 17 00:00:00 2001 From: Max Steffen Date: Mon, 11 Feb 2019 09:06:15 +0100 Subject: [PATCH 21/21] shorter description --- packages/cloud_functions/lib/cloud_functions.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/lib/cloud_functions.dart index 433f4e03fe22..9d131da90e2b 100644 --- a/packages/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/lib/cloud_functions.dart @@ -29,7 +29,7 @@ class CloudFunctions { /// Executes this Callable HTTPS trigger asynchronously. /// /// @param functionName The name of the callable function being triggered. - /// @param region The region where the callable function being triggered. Default is us-central1. + /// @param region The region where the callable function being triggered. Default: us-central1. /// @param parameters Parameters to be passed to the callable function. Future call( {@required String functionName,