[functions] useFunctionsEmulator now stores origin in JS to be sent with each httpsCallable for that instance

This commit is contained in:
Salakar
2019-02-10 05:14:58 +00:00
parent 6a18129028
commit 7fd60acce3
5 changed files with 20 additions and 33 deletions

View File

@@ -35,6 +35,8 @@
(FIRApp *) firebaseApp
region:
(NSString *) region
origin:
(NSString *) origin
name:
(NSString *) name
wrapper:
@@ -45,6 +47,11 @@
(RCTPromiseRejectBlock) reject
) {
FIRFunctions *functions = [FIRFunctions functionsForApp:firebaseApp region:region];
if (origin != nil) {
[functions useFunctionsEmulatorOrigin:origin];
}
FIRHTTPSCallable *callable = [functions HTTPSCallableWithName:name];
[callable callWithObject:[wrapper valueForKey:@"data"] completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
@@ -70,22 +77,6 @@
}];
}
RCT_EXPORT_METHOD(useFunctionsEmulator:
(FIRApp *) firebaseApp
region:
(NSString *) region
origin:
(NSString *) origin
resolver:
(RCTPromiseResolveBlock) resolve
rejecter:
(RCTPromiseRejectBlock) reject
) {
FIRFunctions *functions = [FIRFunctions functionsForApp:firebaseApp region:region];
[functions useFunctionsEmulatorOrigin:origin];
resolve([NSNull null]);
}
- (NSString *)getErrorCodeName:(NSError *)error {
NSString *code = @"UNKNOWN";
switch (error.code) {