How can I use custom domain with call back function in firebase - flutter

I want my flutter app to use the custom domain not the firebase domain when calling the firebase function, and I want to use the callback not the http way, is that possible?
I want to call it this way:
final result = await FirebaseFunctions.instance.httpsCallable('FunctionName').call();
I already connected the custom domain to my firebase project, but now it is not using it, it is just using the firebase domain.

Related

How do I find the origin url of a http request made by a mobile app?

I'm building a mobile app in Flutter that makes an http request to an API. My app doesn't have a backend, so I'm using a tool called KOR Connect to safely handle my API key. The tool requires a list of permitted origins that can make the request. If I was building a web app, I'd simply put in my site's url. However, I don't how to find the origin for mobile app. Is there even such a thing, and if so, where would I find it?
I think you should do it in a different way. You can fetch your api endpoints with fetch method of flutter or you can use a popular library like dio https://pub.dev/packages/dio. this is an example code fetching an api with dio:
final response = await dio.post('https://www.yourwebsite.com/api/login', data: {'email': email, 'password': password});
You can use a backend service like node.js or express.js to write api functionality which you can fetch from your app.
If your request is about CRUD operations and you want to have a database, I would recomend you to check out firebase https://firebase.google.com/, which is the easiest approach to get started by handling data for and from your app. (firebase enviorenment also doesn't need you to handle any kind of secret) its creating a secure connection to your app

How to store response of an api in cache and call api after every 12 hours?

I have an api call that have list of images and text in json response, i want to store json in local and use it in the ui, The api should be called after every 12 hours and save data in cache or the internal storage.
Api call is in the listscreen that opens on a button click.
which one is more suitable. How can i call an api in certain screen even when the app is closed?
Which one is more prefereble to store response cache or using sharedprefrence?
I have used dio and retrofit as sub for the api call.
I tried using Cron and save data in sharedpref.
i tried using flutter cache manager but didnt fit well.
i tried using dio cache mnanager but it didnt work well with retrofit submodule with dio.
Please suggest solution for this.

Flutter how to access Provider Context in FCM backgroundHandler static method?

I have setup background notifications , Hive (To store Notification Locally Using Adapter Class) and Setup a ChangeNotifier ModelClass to get Updates in UI.
Problem: I want to Add Notification data In Hive With ModelClass to get Notified in UI ,If Application is Not Active.
Now I need to access Provider.of(context) in my backgroundHandler which must be a static method where there is no context.
All I need to do is to perform an action according to the data in the background notification.
Same As In this Post

Storing session data in flutter across pages best practice

I have a Flutter app which holds a username and a token to communicate with a web service.
How can I manage the username and token efficiently using best practices? Currently I am writing them into a DB and select them each time I want to do a request.
I tried to use bloc provider flutter bloc with a BlocProvider. I have the states LoggedIn and LoggedOut and the events Login and Logout.
Furthermore, I had a look at
secure storage, but I can't get the data available throughout all pages.
Also, I am not using the firebase API.
Let me know if I should provide some code snippets.
I use SharedPreferences now. The API is very simple and I wrote a wrapper to get rid of the (Strings) keys. Furthermore, the wrapper holds the values for the current session. The advantage of that is, that I can address the values directly instead of needing to read them asynchronously.

how to import JSON data from rest API to google firebase?

I am planning to use Firebase as my backend service for the mobile application. As part of the functionality, I need to get the data from external rest API which returns JSON data. I need to update the data periodically so that I can have updated information.
I have an option to call the rest API and update firebase on the mobile application however it is not the right approach. I prefer to keep this logic on the backend service.
Is there a way to use Firebase cloud function to periodically update firebase database from external Rest API?
#Ioki, I assume what you are trying to do is make a mobile app which gets updated data every time a user goes to the app but you want this to be on the backend. I haven't tried it but you might want to use Node js with their Firebase Admin SDK.
See the link: https://firebase.google.com/docs/admin/setup
Although I think it might make more sense to use the real-time database via the iOS/ Android SDK because automatic/ value event updates are basically the purpose of the real- time database. Good luck! :)