我有一个这样的数据结构:
我正在设置一个云函数来根据特定事件更改所有帖子(子集合)文档,为此我使用collectionGroup
查询:
我是这样设置的:
exports.changeIsVisibleFieldAfterDay = functions.pubsub
.schedule("every 2 minutes").onRun((context) => {
const querySnapshot = db.collectionGroup("Posts")
.where("isVisible", "==", true).get();
querySnapshot.forEach((doc) => {
console.log(doc.data());
});
});
Run Code Online (Sandbox Code Playgroud)
在Firebase Log
我收到以下错误:
TypeError: querySnapshot.forEach is not a function
Run Code Online (Sandbox Code Playgroud)
网上搜索发现Firebase SDK版本可能有问题,但我的是最新的,我package.json
在这里附上文件:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": …
Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-platform google-cloud-functions google-cloud-firestore
我尝试在装有 iOS 15.0.2 的 iPhone 7 上运行应用程序,但收到此错误:
iPhone is busy: Making iPhone ready for development
Run Code Online (Sandbox Code Playgroud)
我在网上搜索并做了所有告诉我要做的事情,包括:
但没有任何改变,我仍然收到相同的加载错误
我重新安装了多次NPM
和Node
在我的电脑。
(npm 版本 7.4.3)
(节点版本 v15.7.0)
我按照以下步骤进行配置Firebase CLI
:
npm install -g firebase-tools
Run Code Online (Sandbox Code Playgroud)
和firebase init
和firebase deploy
和配置似乎工作正常。
当我打开index.js
文件并取消注释股票 helloWorld 函数时,我面临的问题发生了,如下所示:
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)
我运行firebase deploy
并收到此错误
functions[helloWorld(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console. {urlStuff}
Functions deploy had errors with the following functions:
helloWorld
To try redeploying those functions, run: …
Run Code Online (Sandbox Code Playgroud) 我正在以这种方式设置AVPlayer
一个UIView
:
fileprivate func setUpAVPlayer(){
self.cardModel?.urlStrings?.forEach({ (urlString) in
guard let url = URL(string: urlString) else { return }
let asset = AVAsset(url: url)
let playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: nil)
playerItem.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: [.old, .new], context: nil)
self.playerItemArray.append(playerItem)
})
player = AVPlayer(playerItem: playerItemArray[0])
}
Run Code Online (Sandbox Code Playgroud)
在layoutSubviews
我布局显示播放器的playerLayer:
let playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = .resizeAspectFill
self.playerView.layer.insertSublayer(playerLayer, at: 0)
playerLayer.frame = playerView.bounds
Run Code Online (Sandbox Code Playgroud)
在发生某个事件时,我更改播放器的当前项目:
fileprivate func goToNextVideo(){
counter = counter+1
counter = min(playerItemArray.count-1, counter)
self.player?.replaceCurrentItem(with: self.playerItemArray[self.counter])
self.player?.seek(to: .zero) …
Run Code Online (Sandbox Code Playgroud) firebase ×2
avfoundation ×1
avplayer ×1
avplayeritem ×1
javascript ×1
node.js ×1
npm ×1
simulator ×1
swift ×1
xcode ×1