@@ -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 }
0 commit comments