简体   繁体   中英

flutter firebase cloud function emulator, on call functions not working

I use firebase emulator and my cloud functions are in error...

I call my function like that:

HttpsCallable displayNameAndEmail = FirebaseFunctions.instanceFor(region: 'europe-west1').httpsCallable("displayNameAndEmail");

displayNameAndEmail.call({
          'displayName': "$firstName $lastName",
          'lang': lang,
          'email': email
        });
        print("\nDisplayName6\n\n");

And here is the error I get:

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_functions/unavailable] UNAVAILABLE
E/flutter (14049): 
E/flutter (14049): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
E/flutter (14049): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #2      MethodChannelHttpsCallable.call (package:cloud_functions_platform_interface/src/method_channel/method_channel_https_callable.dart:22:24)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #3      HttpsCallable.call (package:cloud_functions/src/https_callable.dart:34:37)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): 
E/flutter (14049): #0      MethodChannelHttpsCallable.call (package:cloud_functions_platform_interface/src/method_channel/method_channel_https_callable.dart:38:7)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #1      HttpsCallable.call (package:cloud_functions/src/https_callable.dart:34:37)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): 

Any idea?

I use firebase emulator and my cloud functions are in error...

I call my function like that :

HttpsCallable displayNameAndEmail = FirebaseFunctions.instanceFor(region: 'europe-west1').httpsCallable("displayNameAndEmail");

displayNameAndEmail.call({
          'displayName': "$firstName $lastName",
          'lang': lang,
          'email': email
        });
        print("\nDisplayName6\n\n");

And here is the error I get :

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [firebase_functions/unavailable] UNAVAILABLE
E/flutter (14049): 
E/flutter (14049): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
E/flutter (14049): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #2      MethodChannelHttpsCallable.call (package:cloud_functions_platform_interface/src/method_channel/method_channel_https_callable.dart:22:24)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #3      HttpsCallable.call (package:cloud_functions/src/https_callable.dart:34:37)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): 
E/flutter (14049): #0      MethodChannelHttpsCallable.call (package:cloud_functions_platform_interface/src/method_channel/method_channel_https_callable.dart:38:7)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): #1      HttpsCallable.call (package:cloud_functions/src/https_callable.dart:34:37)
E/flutter (14049): <asynchronous suspension>
E/flutter (14049): 

Any idea ?

In my case, I have only used it like that. I haven't edited the XML, nor do I need to put localhost 10.0.2.2 for android. Just add your region.

  FirebaseFunctions.instanceFor(region: "us-central").useFunctionsEmulator('localhost', 5001);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM