diff --git a/packages/cloud_functions/CHANGELOG.md b/packages/cloud_functions/CHANGELOG.md index 47cd49f8c1b1..24f1d31384ac 100644 --- a/packages/cloud_functions/CHANGELOG.md +++ b/packages/cloud_functions/CHANGELOG.md @@ -1,3 +1,9 @@ +## 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. + ## 0.1.1+1 * Log messages about automatic configuration of the default app are now less confusing. diff --git a/packages/cloud_functions/example/pubspec.yaml b/packages/cloud_functions/example/pubspec.yaml index 8510d72e0704..673eb83efc24 100644 --- a/packages/cloud_functions/example/pubspec.yaml +++ b/packages/cloud_functions/example/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: cupertino_icons: ^0.1.2 cloud_functions: path: .. - firebase_core: 0.3.0 + firebase_core: ^0.3.1 dev_dependencies: flutter_test: diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 0ac54ac92459..192826cddcc5 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -41,42 +41,42 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result NSString *region = call.arguments[@"region"]; FIRApp *app = [FIRApp appNamed:appName]; FIRFunctions *functions; - if (region != nil) { + if (region != nil && region != (id)[NSNull null]) { functions = [FIRFunctions functionsForApp:app region:region]; } else { functions = [FIRFunctions functionsForApp:app]; } - [functions callFunction: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"]; - } + FIRHTTPSCallable *function = [functions HTTPSCallableWithName:functionName]; + [function 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:[NSString stringWithFormat:@"%ld", error.code] - message:error.localizedDescription - details:nil]; - } - result(flutterError); - } else { - result(callableResult.data); - } - }]; + flutterError = + [FlutterError errorWithCode:@"functionsError" + message:@"Firebase function failed with exception." + details:details]; + } else { + flutterError = [FlutterError + errorWithCode:[NSString stringWithFormat:@"%ld", error.code] + message:error.localizedDescription + details:nil]; + } + result(flutterError); + } else { + result(callableResult.data); + } + }]; } else { result(FlutterMethodNotImplemented); } diff --git a/packages/cloud_functions/ios/cloud_functions.podspec b/packages/cloud_functions/ios/cloud_functions.podspec index 6c1998dd7e1a..cd8a7727235e 100644 --- a/packages/cloud_functions/ios/cloud_functions.podspec +++ b/packages/cloud_functions/ios/cloud_functions.podspec @@ -17,7 +17,7 @@ A new flutter plugin project. s.ios.deployment_target = '8.0' s.dependency 'Flutter' s.dependency 'Firebase/Core' - s.dependency 'Firebase/Functions' + s.dependency 'Firebase/Functions', '~> 5.18' s.static_framework = true end diff --git a/packages/cloud_functions/pubspec.yaml b/packages/cloud_functions/pubspec.yaml index 4efaa4fbc660..7803052c8f40 100644 --- a/packages/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/pubspec.yaml @@ -1,6 +1,6 @@ name: cloud_functions description: Flutter plugin for Cloud Functions. -version: 0.1.1+1 +version: 0.1.2 author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions