根据规范,pushsubscriptionchange事件表明“推送订阅已失效,或即将失效”。处理此事件的最佳做法是什么?
我在我的项目中第一次使用onesignal 。我必须在某些事件上向特定用户(无论用户在 Chrome 或 Android 设备上登录)发送通知,例如 Whatsapp 也会在移动设备和网站上发送通知,并且仅当用户登录时才发送。我已成功向所有人发送通知用户。经过对 OneSignal 的一些研发后,我发现我必须为此目的向特定的玩家 ID 发送通知。但这里有一些我的问题/疑问。
如果有人可以解释这些要点并描述在我的数据库中存储playerid(何时以及如何)的工作流程,我们将不胜感激。
我正在使用 webpush 处理通知。我使用此链接来实现通知网络推送。我正在搜索并应用上周的每个解决方案,但同样的问题我安装了 gmp 并在 xampp/etc/php.ini 中添加
extension = mcrypt.so
Run Code Online (Sandbox Code Playgroud)
这是我的代码
class InvoicePaid extends Notification implements ShouldQueue
{
use Queueable;
public $title, $body;
public function __construct($title, $body)
{
//
$this->title = $title;
$this->body = $body;
}
public function via($notifiable)
{
return [WebPushChannel::class];
}
public function toWebPush($notifiable, $notification)
{
$time = \Carbon\Carbon::now();
return WebPushMessage::create()
// ->id($notification->id)
->title($this->title)
->icon(url('/push.png'))
->body($this->body);
//->action('View account', 'view_account');
}
}
Run Code Online (Sandbox Code Playgroud)
我的路线是
Route::post('/send-notification/{id}', function($id, Request $request){
$user = \App\User::findOrFail($id);
$user->notify(new \App\Notifications\GenericNotification($request->title, $request->body));
return response()->json([
'success' => …Run Code Online (Sandbox Code Playgroud) 有没有办法在显示后删除 Web 推送通知?要将其从设备上的通知列表中删除 - 或将其标记为“已读”?
我认为这不能从服务器完成,我一直在寻找 Javascript API - 但我没有找到任何东西。
(我试图解决的更广泛的问题是如何在多个屏幕/浏览器/设备上同步通知。)
我们可以使用 AWS SNS 服务在移动设备和 Web 浏览器上发送 Web 推送通知吗?
我阅读了SNS的完整文档,但没有找到任何相关内容,只是想确认一下是否支持像下面这样的服务的Web推送通知。
在我正在构建的应用程序中,登录用户可以接收与其用户帐户正在参与或订阅的活动相关的特定推送通知。
就目前而言,如果用户注销,他们仍保持订阅状态,并且 Service Worker 仍保持注册状态。
但是,这意味着他们仍然会收到他们订阅的推送通知。
然而,从好的方面来说,这意味着如果原始用户再次登录,他们将不需要转到自己的首选项并重新启用通知并重新注册新的服务工作线程/订阅。
有没有人有任何示例说明如何以安全的方式处理此问题,以便在注销后不会泄露通知,但在他们重新登录时仍保留现有的订阅?有可能吗?
谢谢,
磷
我目前正在为一个项目开发网络推送通知,并对此事感到有点困惑。我找不到有关该主题的任何信息,因此请考虑以下场景:
所以问题是:
ServiceWorkerRegistration和
PushSubscriptionPWA一样的吗? 我已经使用 Workbox 库实现了一个服务工作者。对于网络推送通知,我们通过 WebPush ( https://github.com/web-push-libs/web-push-csharp )使用 FCM
现在我想要的是发送一个动态推送通知图标。图标以 base64 格式保存在数据库中。当我尝试使用 WebPush 从服务器端发送推送时,它会抛出异常:“错误请求”。
那么是否可以使用 Base64 而不是图像 URL?
在谷歌的开发者页面上,它提到“某些浏览器可能需要通过 HTTPS 提供图像”。那么,这是问题吗?
我尝试通过 webPush 将 base64 发送到 FCM。它没有用。
如果我用 base64 对图标进行硬编码,它就可以工作。
notificationData.icon = 'data:image/png;base64,iVBORw0KGg....'; //its working.
// PUSH NOTIFICATIONS Event
self.addEventListener('push', function(event) {
console.log('[Service Worker]: Received push event', event)
var notificationData = {}
if (event.data.json()) {
notificationData = event.data.json().notification // "notification node is specific for @angular/service-worker
} else {
notificationData = {
title: 'Notification',
message: 'You got notification',
icon: './assets/imgs/notificationicon.jpg' …Run Code Online (Sandbox Code Playgroud) service-worker web-push progressive-web-apps angular workbox
我创建了一个基本的应用程序,尝试使用 web-push 节点库发送推送通知。\n但是,我总是遇到错误:“你必须至少传入一个端点”\n我不明白,因为我“subscribe”(使用 ServiceWorker Api subscribe() 方法),它创建一个到我的本地主机地址的端点
\n\n事实上,我真的不知道该怎么做才能解决这个问题
\n\n这是我的“订阅”代码:
\n\nasync subscribe() {\n const sw = await navigator.serviceWorker.ready; \n const applicationServerPublicKey = \'BADCyHKPTCj1B9Knvmz2_EF1iLieHVZX2eEcCnMLvmMJA2ADlcDILgDC31ztGp1T1TznLpaJ14GQbdIM4APrr6k\';\n const applicationServerKey = this.urlB64ToUint8Array(applicationServerPublicKey);\n console.log("le service worker est " + sw);\n sw.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: applicationServerKey,\n }).then(\n subscription => {\n console.log("User is subscribed with the subscription : ");\n console.log(subscription);\nRun Code Online (Sandbox Code Playgroud)\n\n在控制台上,我可以看到在“订阅”对象中有一个端点\n这里是发送通知的代码:
\n\nconsole.log("Juste avant d\'envoyer la notif on veut envoyer \xc3\xa0 :")\nconsole.log(this.state.endpoint)\n\nwebpush.sendNotification(\n this.state.endpoint,\n payload,\n options\n);\nRun Code Online (Sandbox Code Playgroud)\n\n但我进入控制台:
\n\n\nJuste avant d\'envoyer la notif on …
对于我正在构建的 PWA,我不断收到来自 Chrome 的 WebPush 错误(状态代码 403),并且正文说我需要使用来自“firebase 控制台”的 VAPID 服务器密钥,但我使用了节点 Web-Push 库来生成VAPID 密钥,发生了什么事?我是否必须使用 firebase 在 Chrome 中构建 PWA?
这是我发送推送通知时从浏览器收到的错误消息:
name: 'WebPushError',
message: 'Received unexpected response code',
statusCode: 403,
headers:
{ 'content-type': 'text/plain; charset=utf-8',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-xss-protection': '0',
date: 'Thu, 31 Oct 2019 19:59:02 GMT',
'content-length': '194',
'alt-svc':
'quic=":443"; ma=2592000; v="46,43",h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000',
connection: 'close' },
body:
'the key in the authorization header does not correspond to the sender ID used to subscribe this user. Please ensure …Run Code Online (Sandbox Code Playgroud)web-push ×10
javascript ×2
laravel ×2
php ×2
amazon-sns ×1
angular ×1
onesignal ×1
push-api ×1
workbox ×1