Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit f8078a5

Browse files
collinjacksoniskakaushik
authored andcommitted
[cloud_functions] Specify version for CocoaPod and handle null regions gracefully (#1316)
* Fix for cloud_functions on iOS region is null * Fix build errors due to ambiguous version * Reformat * Update example app firebase_core dependency
1 parent 5567a9c commit f8078a5

5 files changed

Lines changed: 40 additions & 34 deletions

File tree

packages/cloud_functions/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.1.2
2+
3+
* Specifying a version for Cloud Functions CocoaPod dependency to prevent build errors on iOS.
4+
* Fix on iOS when using a null region.
5+
* Upgrade the firebase_core dependency of the example app.
6+
17
## 0.1.1+1
28

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

packages/cloud_functions/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
cupertino_icons: ^0.1.2
1010
cloud_functions:
1111
path: ..
12-
firebase_core: 0.3.0
12+
firebase_core: ^0.3.1
1313

1414
dev_dependencies:
1515
flutter_test:

packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,42 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
4141
NSString *region = call.arguments[@"region"];
4242
FIRApp *app = [FIRApp appNamed:appName];
4343
FIRFunctions *functions;
44-
if (region != nil) {
44+
if (region != nil && region != (id)[NSNull null]) {
4545
functions = [FIRFunctions functionsForApp:app region:region];
4646
} else {
4747
functions = [FIRFunctions functionsForApp:app];
4848
}
49-
[functions callFunction:functionName
50-
withObject:parameters
51-
completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) {
52-
if (error) {
53-
FlutterError *flutterError;
54-
if (error.domain == FIRFunctionsErrorDomain) {
55-
NSDictionary *details = [NSMutableDictionary dictionary];
56-
[details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"];
57-
if (error.localizedDescription != nil) {
58-
[details setValue:error.localizedDescription forKey:@"message"];
59-
}
60-
if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) {
61-
[details setValue:error.userInfo[FIRFunctionsErrorDetailsKey]
62-
forKey:@"details"];
63-
}
49+
FIRHTTPSCallable *function = [functions HTTPSCallableWithName:functionName];
50+
[function callWithObject:parameters
51+
completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) {
52+
if (error) {
53+
FlutterError *flutterError;
54+
if (error.domain == FIRFunctionsErrorDomain) {
55+
NSDictionary *details = [NSMutableDictionary dictionary];
56+
[details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"];
57+
if (error.localizedDescription != nil) {
58+
[details setValue:error.localizedDescription forKey:@"message"];
59+
}
60+
if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) {
61+
[details setValue:error.userInfo[FIRFunctionsErrorDetailsKey]
62+
forKey:@"details"];
63+
}
6464

65-
flutterError =
66-
[FlutterError errorWithCode:@"functionsError"
67-
message:@"Firebase function failed with exception."
68-
details:details];
69-
} else {
70-
flutterError = [FlutterError
71-
errorWithCode:[NSString stringWithFormat:@"%ld", error.code]
72-
message:error.localizedDescription
73-
details:nil];
74-
}
75-
result(flutterError);
76-
} else {
77-
result(callableResult.data);
78-
}
79-
}];
65+
flutterError =
66+
[FlutterError errorWithCode:@"functionsError"
67+
message:@"Firebase function failed with exception."
68+
details:details];
69+
} else {
70+
flutterError = [FlutterError
71+
errorWithCode:[NSString stringWithFormat:@"%ld", error.code]
72+
message:error.localizedDescription
73+
details:nil];
74+
}
75+
result(flutterError);
76+
} else {
77+
result(callableResult.data);
78+
}
79+
}];
8080
} else {
8181
result(FlutterMethodNotImplemented);
8282
}

packages/cloud_functions/ios/cloud_functions.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A new flutter plugin project.
1717
s.ios.deployment_target = '8.0'
1818
s.dependency 'Flutter'
1919
s.dependency 'Firebase/Core'
20-
s.dependency 'Firebase/Functions'
20+
s.dependency 'Firebase/Functions', '~> 5.18'
2121
s.static_framework = true
2222
end
2323

packages/cloud_functions/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: cloud_functions
22
description: Flutter plugin for Cloud Functions.
3-
version: 0.1.1+1
3+
version: 0.1.2
44
author: Flutter Team <[email protected]>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions
66

0 commit comments

Comments
 (0)