最新通知提醒
问题描述:
我正在使用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>
系列后,我可以查看通知警报弹出但是当我点击“允许”它不是扔的通知。
我该如何解决这个问题?
答
您好,我现在在MoEngage工作。智能触发器不是即时的。通知发出前大约需要5分钟的处理时间。你可以做的是等待我们的回调事件(文档 - >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);
});
}
哦嗨感谢您的答复。请提供联系电子邮件地址,以便我询问更多疑问 –
Hi @ zarina-veeru, 您可以通过[https://help.moengage.com/hc/en-us/requests/new ](https://help.moengage.com/hc/en-us/requests/new) – sinapda