我已经使用 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
是否可以在组件上应用这样的类或样式?
元素组件
@Component({
selector: 'app-element',
templateUrl: './element.component.html',
styleUrls: ['./element.component.scss']
})
Run Code Online (Sandbox Code Playgroud)
容器组件模板
<app-element class="button"></app-element>
Run Code Online (Sandbox Code Playgroud)
全局.css
.button {
background :red;
}
Run Code Online (Sandbox Code Playgroud)