是否可以为导航层次结构中的单个视图控制器设置导航栏颜色?让默认的导航栏颜色为红色,行中的最后一个视图控制器应该是蓝色的。我使用这两行来为所述视图控制器的导航栏着色:
navigationController?.navigationBar.barTintColor = .blue
navigationController?.navigationBar.tintColor = .white
Run Code Online (Sandbox Code Playgroud)
但是当返回时(例如按下后退按钮),导航栏保持蓝色。使用上面的代码将颜色设置回红色不会做任何事情。
我希望我的 Cloud Function 向特定主题发送推送通知,这很好用。但是,当我添加“徽章”字段时,会出现以下错误:
Unknown name "badge" at 'message.notification': Cannot find field.
Run Code Online (Sandbox Code Playgroud)
如果我想为 iOS 设备指定徽章编号,我该怎么做?我的代码如下所示:
exports.onAddLog = functions.database.ref("/NodesLog/{id}").onCreate((change, context) => {
const payload = {
"topic": "Channel123",
"notification": {
"title": "Test-Title",
"body": "Test-Body",
"badge": "1"
},
"data": {
"test": "test",
"notId": "123"
}
}
const promise : Promise<any> = admin.messaging().send(payload)
.catch(error => console.error("Error on send: " + error))
.then(sendSuccess => console.log("Notification send "))
.catch(() => console.error("What happened?"))
return promise;
})
Run Code Online (Sandbox Code Playgroud)