参考:https://github.com/firebase/quickstart-js/tree/master/messaging
我添加了键值对:
"requireInteraction": true
Run Code Online (Sandbox Code Playgroud)
但桌面Chrome中的通知在20秒后仍然消失.有人知道Firebase是否支持这个键值对吗?谢谢!
我的例子如下.请换[...]到你的.
curl -X POST -H "Authorization: key=[...]" -H "Content-Type: application/json" -d '{
"notification": {
"requireInteraction": true,
"title": "This is custom title",
"body": "this is custom body",
"click_action": "https://google.com",
"data" : {"requireInteraction": true }
},
"to": "[...]",
}' "https://fcm.googleapis.com/fcm/send"
Run Code Online (Sandbox Code Playgroud) javascript google-chrome push-notification firebase firebase-cloud-messaging
https://example.com触发 ajax 预请求(beforeSend)到https://api.example.com (nginx)
$.ajax({
method: "POST",
url: 'https://api.example.com',
xhrFields: {withCredentials: true},
data: {...},
success: function(msg) {...},
beforeSend: function(request){
var token = 'xxxxxx';
request.setRequestHeader('Authorization', 'Bearer ' + token);
},
complete: function(msg) {},
error: function(xhr, ajaxOptions, thrownError) {}
});
Run Code Online (Sandbox Code Playgroud)
Chrome 控制台返回错误消息
XMLHttpRequest 无法加载https://api.example.com/auth。预检响应中的 Access-Control-Allow-Headers 不允许请求标头字段授权。
我可以使用内存来迁移我的数据库并启动服务器吗?
我的/配置/数据库.php
'sqlite' => array(
'driver' => 'sqlite',
'database' => ':memory:', // fail
// 'database' => 'database', // success
'prefix' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
),
Run Code Online (Sandbox Code Playgroud)
并迁移表并启动laravel服务
$ php artisan migrate:refresh
$ php artisan serve
Run Code Online (Sandbox Code Playgroud)
我使用 driver=sqlite + database=database 一切正常,
我使用driver=sqlite + database=:memory,错误信息来自127:0.0.1 说数据库表尚未创建。