This quickstart demonstrates Callable Functions which are HTTPS Cloud Functions that can be invoked directly from your mobile application.
- Add Firebase to your iOS Project.
- Set up Firebase Functions Functions in the docs should be updated, since the functions applied in the quickstart might not be the same as the ones in the example from the doc above.
To align with the quickstart, the index.js
should be updated to
const functions = require('firebase-functions');
exports.addNumbers = functions.https.onRequest((request, response) => {
var first = Number(request.body.data.firstNumber);
var second = Number(request.body.data.secondNumber);
response.json({ data: {operationResult: first + second} });
});
exports.capitalizeMessage = functions.https.onRequest((request, response) => {
var upText = request.body.data.text;
response.json({ data: {text: upText.toUpperCase()} });
});
-
Run on a local machine To let the quickstart run on a local machine, you can Emulate execution of your functions locally by adding a flag
-D EMULATOR
to theOther Swift Flags
under theBuild Settings
. -
Run in production Once functions are deployed to a production environment, the Functions quickstart can just build and run without additional settings to connect to a Firebase project. Remember to remove the
-D EMULATOR
flag if you ran the quickstart through an emulator before.
Copyright 2022 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.