Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
Firebase Cloud Functions will not fire from iOS app

I'm building an iOS app using Firebase for the backend and need to use Firebase Callable Cloud Functions. I have everything set up as per docs and functions fire and behave as expected when launched from browser or curl but I cannot get them to fire from my app.

I've set up a test app just using the functions and I cannot get that to fire from iOS app either. Not even a basic hello world. Nothing is getting through.

All of the following has been done:

Firebase side:

  1. Firebase is connected to app successfully
  2. Installed/Initialised the Firebase Functions locally.
  3. Written function code in VSCode trying both Javascript and TypeScript
  4. Successfully deployed to Firebase and can see function in console
  5. Tested function via command line and browser on local server all works as expected

iOS side:

  1. Pod installed Firebase functions
  2. imported Firebase functions into ViewController
  3. Used Firebase SDK to invoke function matching name of function on Firebase - attached to button trigger

And I get nothing... the print statement on the button works but the function doesn't fire and nothing gets logged to Firebase logs.

What am I missing or doing wrong here?

Tried new project with new instance of Firebase. Copied code directly from examples on Firebase docs and followed everything step by step

FIREBASE CODE

const functions = require('firebase-functions');
const admin = require('firebase-admin')

exports.helloWorld = functions.https.onCall((data, context) => {

    const text = data.text;
    console.log("Text: " + text);
    const uid = context.uid;
    console.log("UID: " + uid);
    const name = context.name;
    console.log("Name: " + name);


    console.log('Hello world fucking worked baby!');
    return {
        message: text
    }
});

SWIFT CODE

import UIKit
import FirebaseFunctions

class ViewController: UIViewController {

    lazy var functions = Functions.functions()

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func fireFunction(_ sender: Any) {
        print("Button Fire")

        let data = ["text": "hello!"]

        functions.httpsCallable("helloWorld").call(data) { (result, error) in
            print("Function returned")
            if let err = error {
                print(err)
            }

            if let res = result {
                print(res)
            }
        }
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It seems that the Google Cloud Function is working properly if it is being called from a browser. You can also view the LOGs of the Cloud Function. Simply go to the Cloud Functions page and click on your function. Click on the VIEW LOGS button and try calling the URL again, if there is an error with the way Swift calls it, it will be logged there.

I have not worked with iOS Swift very much, but since you are trying to call the function via internet, I am thinking that you might need to give permissions to the App to access the Internet. It looks like the call is never initiated in the Cloud Function, that is why it is not triggered.

I assume that the Cloud Function is an HTTP triggered one. Therefore as a workaround, you can call the function initiating an HTTP request from the App. Again, this won't work though, unless you make sure that your App has the permissions to use the internet.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda