-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonesignal.html
More file actions
29 lines (26 loc) · 1.81 KB
/
onesignal.html
File metadata and controls
29 lines (26 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html lang="ko-KR">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>
<script>
window.OneSignalDeferred = window.OneSignalDeferred || [];
OneSignalDeferred.push(function(OneSignal) {
OneSignal.init({
appId: "3e056ceb-bf3c-4ca1-b0a6-f12b2b8319bc"
});
});
</script>
<style>
.disabled {
background-color: #222;
}
</style>
</head>
<body>
<h1>Hello, Web Push</h1>
<button type="button" onclick="sendFlareLaneDemoNotification(this)">Send Demo Notification</button>
<div id="logs"></div>
<script>function sendFlareLaneDemoNotification(e){const i=()=>{e.disabled=!1,e.classList.remove("disabled")},t={API_URL:"https://staging-service-api.flarelane.com/send-demo-notification",DRAFT_STORE_ID:"flarelane_dndly",delayTime:3e3,isIOS:/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,fetch:{method:"POST",headers:{"Content-Type":"application/json"}},class:{disabled:"disabled"}},a="iOS 웹 푸시는 지원 예정입니다. 안드로이드 폰이나 PC 환경에서 다시 시도해보세요.",d="잠시 후 구독 팝업이 노출됩니다. 조금만 기다려주세요!",n="왼쪽 아래 종 모양 버튼을 클릭하여 알림 구독을 먼저 진행하세요.";try{if(t.isIOS)return void alert(a);if(!FlareLane.initialized)return void alert(d);e.disabled=!0,e.classList.add("disabled"),FlareLane.getIsSubscribed((e=>{e?FlareLane.getDeviceId((function(e){if(fetch)return e?void fetch(t.API_URL,{method:t.fetch.method,headers:t.fetch.headers,body:JSON.stringify({deviceId:e})}).then((function(){setTimeout((()=>{i()}),t.delayTime)})).catch((function(){i()})):(alert(n),void i());i()})):(alert(n),i())}))}catch{i()}}</script>
</body>
</html>