Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Hridoy · Apr 04, 2018 at 03:31 PM · networkingplugin

How to call http callable functions in firebase with unity?

Firebase has recently launched the facility to directly call cloud functions from mobile devices which I think is a really great feature. Details

But the thing is, I can not find any documentation on how to call these functions in unity. Does the official plugin supports it? How am I supposed to call the functions?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by figurefurther · Jun 11, 2018 at 06:43 AM

You probably already figured this out, but I figured I would share what I have found with experimentation for anyone else stumbling across this thread. You can use the http callable functions with Unity. It's actually pretty easy. Use the WWW method (documentation here) to access the url for your function (which will be provided when you deploy your cloud function).

For example, I did firebase's Get Started addMessage function as a test (here) which is an https callable function that adds whatever text you append to the url to a "messages" node in the realtime database. My C# code was pretty simple, I made the base url as a string and then a public string where I could add whatever text I wanted in the inspector for testing purposes, concatenated those into another string variable and fed that into the WWW method (I just cut and paste the example code from the above link to the documentation for retrieving textures, but changed it from textures to simply text and fed that into the debug.log just to see what it gave me--it gave me the html from the database, but I didn't need it, I was just curious). Bing, bang, boom, the text showed up in my firebase just like when I did it through a browser. Pretty slick!

So, long story short--use the WWW method to access the url that firebase will give you for the function you want to run and it will do it's thing. If you are looking to get information back from the browser, that will probably be a little trickier since Unity doesn't have a huge amount of options for what you can retrieve from the url in return (mostly assets like images, movies, and textures--but I haven't played with it too much).

You can also run your cloud functions triggered by events that occur on the backend, and that has nothing to do with Unity so I don't think it should be an issue. For example, you can have functions run when you change data in the realtime database (which I have been able to successfully add and retrieve data from my unity project, but I haven't set it up so that functions are triggered when I do that--but again, it is only dependent on data changing in the database, it doesn't care how the data was changed).

The one catch is that you have to write your functions in javascript (or typescript--your choice), so if you have been using C# for unity, then you'll have to spend some time learning a new language (it's not too difficult--I recommend using either freecodecamp or Mozilla Development Network--both have excellent tutorials that will have you up and running in no time). Google firebase also has a Git repo with a couple dozen examples for both https callable functions as well as event triggered functions. All in all, I am pretty psyched that I found firebase, easy to use and loads more things that all tie into the database and cloud functions (auth, analytics, messaging, and much much more).

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JamesKR · Aug 09, 2020 at 05:24 PM 0
Share

Hey man just wondering how you actually invoke the function URL? everything else is working fine but once i receive the Unity Web Request Im not sure how to invoke it. Cheers

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

172 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to create plugin with network suff (NetwrokBehaviour, SyncVar etc) ? 0 Answers

PLS recommend plugins for networking/sever which ONLY work for authentication + storing player info. 0 Answers

Send Text Over Network 0 Answers

Photon not working/detected 2 Answers

ClientRpc doesnt call on local client 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges