2017-10-13 53 views
0

我正在使用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> 

系列後,我可以查看通知警報彈出但是當我點擊「允許」它不是扔的通知。

我該如何解決這個問題?

回答

0

您好,我現在在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); 
 
    }); 
 
}

+0

哦嗨感謝您的答覆。請提供聯繫電子郵件地址,以便我詢問更多疑問 –

+0

Hi @ zarina-veeru, 您可以通過[https://help.moengage.com/hc/en-us/requests/new ](https://help.moengage.com/hc/en-us/requests/new) – sinapda