【问题标题】:Latest Notification alerts最新通知提醒
【发布时间】:2017-10-13 07:21:59
【问题描述】:

我正在使用https://www.moengage.com/ 为我的桌面和移动用户生成智能触发活动通知警报。 使用他们的<link rel="manifest" href="manifest.json">

<script type="text/javascript">
(function(i,s,o,g,r,a,m,n){
i['moengage_object']=r;t={}; q = function(f){return function(){(i['moengage_q']=i['moengage_q']||[]).push({f:f,a:arguments});};};
f = ['track_event','add_user_attribute','add_first_name','add_last_name','add_email','add_mobile',
'add_user_name','add_gender','add_birthday','destroy_session','add_unique_user_id','moe_events','call_web_push','track','location_type_attribute'];
for(k in f){t[f[k]]=q(f[k]);}
a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);
i['moe']=i['moe'] || function(){n=arguments[0];return t;}; a.onload=function(){if(n){i[r] = moe(n);}};
})(window,document,'script','https://cdn.moengage.com/webpush/moe_webSdk.min.latest.js','Moengage'); 

Moengage = moe({
  app_id:"MyAppID",
  debug_logs: 0
}); 
</script>

广告系列已创建,我可以查看弹出的通知警报,但是当我单击“允许”时,它不会抛出通知。

我该如何解决这个问题?

【问题讨论】:

    标签: php push-notification moengage


    【解决方案1】:

    您好,我目前在 MoEngage 工作。智能触发器不是即时的。在发出通知之前有大约 5 分钟的处理时间。您可以做的是等待我们的回调事件(docs -> https://docs.moengage.com/docs/tracking-opt-ins-on-your-own#section-this-is-how-you-can-add-listeners-for-the-events-mentioned-above-)并通过 javascript 显示欢迎通知。

    ...
    else if (e.detail == "opt_in_allowed") {
      spawnNotification();
    }
    ...
    
    function spawnNotification() {
      var title = "Your title";
      var body = "Your body";
      var icon = "https://path.to.your/icon/file";
      var options = {
        body: body,
        icon: icon
      };
      navigator.serviceWorker.ready.then(function(sw_reg) {
        var n = sw_reg.showNotification(title, options);
      }).catch(function(e) {
        console.log(e);
      });
    }

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    相关资源
    最近更新 更多