| 157 | } |
| 158 | |
| 159 | httpsCallable(name: string, options?: HttpsCallableOptions): HttpsCallable { |
| 160 | const callable = this.native.getHttpsCallable(name); |
| 161 | if (typeof options?.timeout === 'number') { |
| 162 | callable.setTimeout(options.timeout, java.util.concurrent.TimeUnit.SECONDS); |
| 163 | } |
| 164 | return (data: any) => { |
| 165 | return new Promise((resolve, reject) => { |
| 166 | org.nativescript.firebase.functions.FirebaseFunctions.call( |
| 167 | callable, |
| 168 | data ? serialize(data, true) : null, |
| 169 | new org.nativescript.firebase.functions.FirebaseFunctions.Callback<com.google.firebase.functions.HttpsCallableResult>({ |
| 170 | onSuccess(result: com.google.firebase.functions.HttpsCallableResult): void { |
| 171 | resolve(deserialize(result?.getData?.())); |
| 172 | }, |
| 173 | onError(error): void { |
| 174 | reject(toHttpsError(error)); |
| 175 | }, |
| 176 | }) |
| 177 | ); |
| 178 | }); |
| 179 | }; |
| 180 | } |
| 181 | |
| 182 | useEmulator(host: string, port: number) { |
| 183 | this.native.useEmulator(host === 'localhost' || host === '127.0.0.1' ? '10.0.2.2' : host, port); |