@@ -35,10 +35,18 @@ namespace internal {
3535 " (Ljava/lang/String;)" \
3636 " Lcom/google/firebase/functions/HttpsCallableReference;" , \
3737 util::kMethodTypeInstance ), \
38+ X (GetHttpsCallableWithOptions, " getHttpsCallable" , \
39+ " (Ljava/lang/String;Lcom/google/firebase/functions/HttpsCallableOptions;)" \
40+ " Lcom/google/firebase/functions/HttpsCallableReference;" , \
41+ util::kMethodTypeInstance ), \
3842 X (GetHttpsCallableFromURL, " getHttpsCallableFromUrl" , \
3943 " (Ljava/net/URL;)" \
4044 " Lcom/google/firebase/functions/HttpsCallableReference;" , \
4145 util::kMethodTypeInstance ), \
46+ X (GetHttpsCallableFromURLWithOptions, " getHttpsCallableFromUrl" , \
47+ " (Ljava/net/URL;Lcom/google/firebase/functions/HttpsCallableOptions;)" \
48+ " Lcom/google/firebase/functions/HttpsCallableReference;" , \
49+ util::kMethodTypeInstance ), \
4250 X (UseFunctionsEmulator, " useFunctionsEmulator" , \
4351 " (Ljava/lang/String;)V" , \
4452 util::kMethodTypeInstance )
@@ -50,6 +58,21 @@ METHOD_LOOKUP_DEFINITION(firebase_functions,
5058 " com/google/firebase/functions/FirebaseFunctions" ,
5159 FIREBASE_FUNCTIONS_METHODS )
5260
61+ // clang-format off
62+ #define CALLABLE_OPTIONS_METHODS (X ) \
63+ X (BuilderConstructor, " <init>" , " ()V" ), \
64+ X (SetLimitedUseAppCheckTokens, " setLimitedUseAppCheckTokens" , \
65+ " (Z)Lcom/google/firebase/functions/HttpsCallableOptions$Builder;" ), \
66+ X (Build, " build" , " ()Lcom/google/firebase/functions/HttpsCallableOptions;" )
67+ // clang-format on
68+
69+ METHOD_LOOKUP_DECLARATION (callable_options_builder, CALLABLE_OPTIONS_METHODS )
70+ METHOD_LOOKUP_DEFINITION (
71+ callable_options_builder,
72+ PROGUARD_KEEP_CLASS
73+ " com/google/firebase/functions/HttpsCallableOptions$Builder" ,
74+ CALLABLE_OPTIONS_METHODS )
75+
5376// clang-format off
5477#define FUNCTIONS_EXCEPTION_METHODS (X ) \
5578 X (GetMessage, " getMessage" , " ()Ljava/lang/String;" ), \
@@ -125,6 +148,7 @@ bool FunctionsInternal::Initialize(App* app) {
125148 functions_exception::CacheMethodIds (env, activity) &&
126149 functions_exception_code::CacheMethodIds (env, activity) &&
127150 functions_exception_code::CacheFieldIds (env, activity) &&
151+ callable_options_builder::CacheMethodIds (env, activity) &&
128152 // Call Initialize on all other Functions internal classes.
129153 HttpsCallableReferenceInternal::Initialize (app))) {
130154 return false ;
@@ -144,6 +168,7 @@ void FunctionsInternal::Terminate(App* app) {
144168 firebase_functions::ReleaseClass (env);
145169 functions_exception::ReleaseClass (env);
146170 functions_exception_code::ReleaseClass (env);
171+ callable_options_builder::ReleaseClass (env);
147172
148173 // Call Terminate on all other Functions internal classes.
149174 HttpsCallableReferenceInternal::Terminate (app);
@@ -186,14 +211,37 @@ Error FunctionsInternal::ErrorFromJavaFunctionsException(
186211
187212HttpsCallableReferenceInternal* FunctionsInternal::GetHttpsCallable (
188213 const char * name) const {
214+ return GetHttpsCallable (name, HttpsCallableOptions ());
215+ }
216+
217+ HttpsCallableReferenceInternal* FunctionsInternal::GetHttpsCallable (
218+ const char * name, const HttpsCallableOptions& options) const {
189219 FIREBASE_ASSERT_RETURN (nullptr , name != nullptr );
190220 JNIEnv* env = app_->GetJNIEnv ();
221+
222+ // Create HttpsCallableOptions
223+ jobject builder = env->NewObject (
224+ callable_options_builder::GetClass (),
225+ callable_options_builder::GetMethodId (callable_options_builder::kBuilderConstructor ));
226+ jobject builder2 = env->CallObjectMethod (
227+ builder,
228+ callable_options_builder::GetMethodId (callable_options_builder::kSetLimitedUseAppCheckTokens ),
229+ options.limited_use_app_check_token );
230+ env->DeleteLocalRef (builder);
231+ builder = builder2;
232+ jobject java_options = env->CallObjectMethod (
233+ builder,
234+ callable_options_builder::GetMethodId (callable_options_builder::kBuild ));
235+ env->DeleteLocalRef (builder);
236+
191237 jobject name_string = env->NewStringUTF (name);
192238 jobject callable_reference_obj = env->CallObjectMethod (
193239 obj_,
194- firebase_functions::GetMethodId (firebase_functions::kGetHttpsCallable ),
195- name_string);
240+ firebase_functions::GetMethodId (firebase_functions::kGetHttpsCallableWithOptions ),
241+ name_string, java_options );
196242 env->DeleteLocalRef (name_string);
243+ env->DeleteLocalRef (java_options);
244+
197245 if (util::LogException (env, kLogLevelError ,
198246 " Functions::GetHttpsCallable() (name = %s) failed" ,
199247 name)) {
@@ -208,15 +256,38 @@ HttpsCallableReferenceInternal* FunctionsInternal::GetHttpsCallable(
208256
209257HttpsCallableReferenceInternal* FunctionsInternal::GetHttpsCallableFromURL (
210258 const char * url) const {
259+ return GetHttpsCallableFromURL (url, HttpsCallableOptions ());
260+ }
261+
262+ HttpsCallableReferenceInternal* FunctionsInternal::GetHttpsCallableFromURL (
263+ const char * url, const HttpsCallableOptions& options) const {
211264 FIREBASE_ASSERT_RETURN (nullptr , url != nullptr );
212265 JNIEnv* env = app_->GetJNIEnv ();
266+
267+ // Create HttpsCallableOptions
268+ jobject builder = env->NewObject (
269+ callable_options_builder::GetClass (),
270+ callable_options_builder::GetMethodId (callable_options_builder::kBuilderConstructor ));
271+ jobject builder2 = env->CallObjectMethod (
272+ builder,
273+ callable_options_builder::GetMethodId (callable_options_builder::kSetLimitedUseAppCheckTokens ),
274+ options.limited_use_app_check_token );
275+ env->DeleteLocalRef (builder);
276+ builder = builder2;
277+ jobject java_options = env->CallObjectMethod (
278+ builder,
279+ callable_options_builder::GetMethodId (callable_options_builder::kBuild ));
280+ env->DeleteLocalRef (builder);
281+
213282 jobject url_object = util::CharsToURL (env, url);
214283 jobject callable_reference_obj =
215284 env->CallObjectMethod (obj_,
216285 firebase_functions::GetMethodId (
217- firebase_functions::kGetHttpsCallableFromURL ),
218- url_object);
286+ firebase_functions::kGetHttpsCallableFromURLWithOptions ),
287+ url_object, java_options );
219288 env->DeleteLocalRef (url_object);
289+ env->DeleteLocalRef (java_options);
290+
220291 if (util::LogException (
221292 env, kLogLevelError ,
222293 " Functions::GetHttpsCallableFromURL() (url = %s) failed" , url)) {
0 commit comments