小编Mat*_*w M的帖子

AngularFire2 (@angular/fire) 如何从可调用函数中获取错误?

我正在尝试使用 Angular Fire 包访问 Angular 环境中可调用函数的错误消息。请看下面的代码:

角度(客户端)

async myCallableFunction(id: string) {
  try {
    const res = await this.afFunctions.httpsCallable('callableFunction')({
      id
    }).toPromise();

    console.log(res);
  } catch (err) {
    console.error('Error is:', err);
  }
}
Run Code Online (Sandbox Code Playgroud)

服务器端(Firebase 功能)

exports.callableFunction = functions.https.onCall((data: {
 id: string
}, context: https.CallableContext) => {
  // throw error for testing only
  throw new https.HttpsError('unknown', 'Test Error Message');
});
Run Code Online (Sandbox Code Playgroud)

控制台记录的错误消息是:

[console.error]:“错误是:”{“代码”:“未知”,“行”:100205,“列”:32,“sourceURL”:“ http://192.168.1.100:8100/vendor.js ” }

如何从 Cloud Firestore 的响应中访问错误消息?

提前致谢。

error-handling typescript angularfire google-cloud-functions angularfire2

6
推荐指数
1
解决办法
375
查看次数

如何通过发布/订阅将Google Play实时开发者通知连接到Firebase Cloud Function?

我正处于开发新移动应用程序的最后阶段,但似乎找不到找到一种方法,以允许Google Play实时开发者通知通过推荐的Google Pub / Sub方法与Firebase云功能进行通信。

预期的有效负载流应如下所示:

用户通过Play商店购买订阅 > Play商店将RT Dev通知发送到Pub / Sub > Pub / Sub将消息发送到Firebase云功能 > 云功能运行并带有有效负载

我目前以类似的方式设置了一个Apple Developer Webhook,该Webhook将收据有效载荷钩到我已设置的iOS云功能上。

在发布/订阅设置阶段,发布/订阅页面要求验证云功能URL,因为我不是真正的云功能域网站管理员,所以我无法执行此操作,因此暂停了“添加实时开发人员”的工作Google提供的“通知”文档。

有没有办法让RT通知绕过Google Pub / Sub并直接进入Webhook或通过另一种方式完成上述流程,从而将实时通知发送到Pub / Sub云功能或HTTPS云功能?

最终目的是提供一种方法来确保所进行的购买实际上是有效的购买,而不是某人拦截客户端>服务器Webhook并提交自己的一个协议而提出的伪造请求。

google-play firebase google-cloud-pubsub google-cloud-functions google-play-console

6
推荐指数
1
解决办法
104
查看次数