小编Abi*_*bal的帖子

Firebase Web 推送通知无法正常工作 messages.onMessage

我已将网络推送通知配置到我的 PWA ionic 4 应用程序。当选项卡切换时,即在后台或我的应用程序之外,网络推送通知就像魅力一样工作。

问题是,当选项卡处于活动状态时,我会在 chrome 检查的应用程序部分收到推送消息,但没有触发任何通知。

下面是代码:

应用程序组件.ts

async ngOnInit() {
firebase.initializeApp(environment.firebase);
}

ngAfterViewInit() {
   this.platform.ready().then(async () => {
   await this.notificationsService.requestPermission();
   });
}
Run Code Online (Sandbox Code Playgroud)

通知.service.ts

export class NotificationsService {
  init(): Promise<void> {
    return new Promise<void>((resolve, reject) => {
      navigator.serviceWorker.ready.then(
    registration => {
      // Don't crash an error if messaging not supported
      if (!firebase.messaging.isSupported()) {
        resolve();
        return;
      }

      const messaging = firebase.messaging();

      // Register the Service Worker
      messaging.useServiceWorker(registration);

      // Initialize your VAPI key
      messaging.usePublicVapidKey(environment.firebase.vapidKey);


      // Listen to messages when your …
Run Code Online (Sandbox Code Playgroud)

web-notifications ionic-framework progressive-web-apps angular ionic4

6
推荐指数
1
解决办法
3706
查看次数

使用meteor触发sendgrid模板电子邮件

我正在使用sendgrid发送电子邮件.我想将模板作为电子邮件发送给用户.下面的代码只是发送简单的基于文本的电子邮件,而不是定义标题部分和使用模板ID.

if (Meteor.isServer) {
    Email.send({
        from: "from@mailinator.com",
        to: "abc@mail.com",
        subject: "Subject",
        text: "Here is some text",
        headers: {"X-SMTPAPI": {
            "filters" : {
                "template" : {
                    "settings" : {
                        "enable" : 1,
                        "Content-Type" : "text/html",
                        "template_id": "3fca3640-b47a-4f65-8693-1ba705b9e70e"
                    }
                }
            }
        }
        }



    });
}
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助.

最好

sendgrid meteor sendgrid-templates

5
推荐指数
1
解决办法
250
查看次数