Google 在应用程序购买中 google 在 firebase 上玩商店:)

Google in app purchases google play store on firebase : )

我是一名年轻的女性开发人员,但目前我正在为我们公司的一个大客户构建一个项目,

我有一个问题,实际上你们中的一个人可能会引导我朝着正确的方向前进:

我有一个 firebase 帐户和一个支持应用内购买的应用 - 应用内购买实际上包含我想存储在 firebase 服务器上并在购买后下载的视频!有人可以指导我如何以最简单的方式实现这一点吗?

Ps.,我知道我是菜鸟,但我真的不想在下个月的会议上看起来像个白痴; )

此致,拉娜

老实说,没有简单的方法可以保护 file/folder 使用 Firebase 云存储的特定用户组。您可以通过更改文件夹元数据或使用自定义令牌来进行检查,但是您需要一个服务器等...

如果您希望留在仅限 firebase 的环境中,最简单的方法可能是将受保护的视频托管在所有客户端的受保护文件夹中。当用户购买视频时,然后按照以下行发送 CloudFunction 请求..

userClaimsToHaveBoughtAccessToVideo(userId, sku, token, videoId){
// 1. use the googlePlay billing API to verify that the user did indeed purchase the item
// 2. if they did, then store that in read-only node of the database like: /purchasedVideos/userId/videoID/
}

然后,如果用户想要下载视频,请按照...

创建一个函数
userWantsToDownloadAVideo(userId, videoId){
 // check the database to see if the user has the video
 // if they do, copy the video file to a folder like /userId/videos/...
}

然后视频将出现在个人文件夹中,该文件夹的安全规则很容易设置。

当用户将视频下载到他们的设备时,按照以下方式发送对函数的调用..

userDownloadedVideo(userId, videoId){
  // delete video from the user's folder, to save space
}

另一种选择是将视频完全托管在另一个平台上,该平台具有 API 并允许其文件受密码保护。 (然后只需在数据库中验证 IAP 后存储访问密码,对用户只读),这样他们就可以使用其他 API 下载视频。为了安全起见,您可能希望每天重新生成密码并更新数据库。