• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在 iOS 中为 Firebase 使用 Cloud Functions

[复制链接]
菜鸟教程小白 发表于 2022-12-12 14:23:54 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我使用 Node.js 为 Firebase 编写了一个云函数。

exports.fetchStudents = functions.https.onRequest((request, response) => {
    return admin.database().ref('Student').once('value', (snapshot) => {
        var students = snapshot.val();
        response.send(students)
        console.log(students)
    });
});

我已将它部署在 Firebase Server 和控制台上,我得到了所需的值。 我不想在我的 iOS 应用程序中使用此功能。我真的不知道如何在我的 iOS 应用中使用这些功能。

谢谢



Best Answer-推荐答案


我已经做到了,这很容易。您需要的是在成功上传函数后点击 CLI 提供的 url。

Function URL (helloWorld): https://us-central1-project-id.cloudfunctions.net/helloWorld.

将 project-id 替换为您的项目 ID。

let url = URL(string:  "https://us-central1-project-id.cloudfunctions.net/fetchStudents")!

let urlReq = URLRequest(url: url)

let students = Alamofire.request(urlReq).validate().responseJSON { (response) in
         switch response.result{
           case .success(let value):
              completion(JSON(value), nil)
           case .failure(let error):
              completion(nil, String(describing: error))
        }
     }

关于ios - 在 iOS 中为 Firebase 使用 Cloud Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47901274/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap