Webããã·ã¥æè¡ãæµè¡ã£ã¦ããã®ã§è©¦ãã«å®è£
åã³ã¾ã¨ãã¦ã¿ã¾ãã。
ç°å¢ã¯ä»¥ä¸ã«è¨è¼ã§ãã、localhostã§è©¦é¨çã«ãã£ã¦ã¿ãã人åãã«æ¸ãã¦ãã¾ã。
OneSignalã¨ãããµã¼ãã¹ãå©ç¨ãã¦å¯¾å¿ãã¦ã¿ã¾ããã以ä¸ã®çç±ã§å¯¾å¿ãã¾ãã。ä»ã«è¯ããã®ããããããããªãã§ããèªåã®ä¸ã§ã¯ãããä¸çªãã£ãããã¾ãã。
ç¡æã§å©ç¨ã§ãã
éSSLã§å©ç¨å¯è½
Mac & Windowsç³»ã®ä¸»è¦ãã©ã¦ã¶å¯¾å¿(iOSã¯é対å¿)
æ©éæ¤è¨¼ç°å¢ãç¾
å
ç°å¢ | æ¦è¦ |
2017/08/19æ¥æ¤è¨¼ | |
ããã·ã¥ãµã¼ãã¹ | OneSignal |
Webãµã¼ã | macOS Sierraä¸ã«apache(Apache/2.4.25) |
ãã¹ã | http://localhost/~{ã¦ã¼ã¶å}/ |
åºæ¬çã«Macã触ã£ã¦ããã°åæç¶æ
?ã§å©ç¨ã§ãããã®ãåæã«ãã¦ã¿ã¾ãã。
http://localhost/index.htmlã«å®ç¾ããã¤ã¡ã¼ã¸ã§ã。
1.ãµã¤ãã«ç»é²
https://onesignal.com/
ã«ç»é²、ç»é²ã«ã¯ã¡ã¢ã&ãã¹ã¯ã¼ãã§OK
GitHubã¨ããã®ä»ã§ãå¯
ç»é²ä½æ¥ã¯æ¬è³ªã§ã¯ãªãã®ã§çç¥
2.æ°ããããã¸ã§ã¯ãã®è¨å®(Safariç·¨)
2-1.ããã¸ã§ã¯ãåã®å
¥å
Add a new app
ãæ¼ãæ°è¦ä½æ
ããã¯èªåã§é©å½ã«æ±ºããä»åã¯`Test’ã§ä½æ
2-2.WebSite Pushãæå®
ä½ãèãã
WebSiet Push
ãé¸æ
2-3.Apple Safariãæå®
ã¾ã㯠Safariã®è¨å®ãããã®ã§
Apple Safari
ãæå®
2-4.ãã¹ããµã¤ãæ
å ±ãæå®
å¿
é å
¥åã、ï¼ã¤ã§
Site Name
ããã¯é©å½ã§è¯ãä»åã¯
Test1
ãæå®
Site URL
ããã«
http://localhost
ãæå®
æ®ãï¼ã¤ã¯è£½åããªãªã¼ã¹ããã®ãªã触ã£ãæ¹ãè¯ããã¨ãå¾ãä»ã¯æ¾ç½®
2-5.SDKã®æå®
ä½ãèãã
Websiet Push
ãé¸æ
2-6.Testå®è¡
ãã®ç»é¢ã«æ¥ãã¨ï¼ã¤ã®ãã¨ãããå¿
è¦ããã
1. æ¿èªç¨HTMLã®ä½æ
2. ãã©ã¦ã¶ããæ¿èª
ã¾ãã¯、
æ¿èªç¨HTMLã®ä½æ
ãã
# sudo vi /Library/WebServer/Documents/index.html.en
以ä¸ã®ã½ã¼ã¹ãè¨è¼
<html>
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async='async'></script>
<script>
var OneSignal = window.OneSignal || [];
OneSignal.push(["init", {
appId: "{Your App IDãç½®ãæã}",
httpPermissionRequest: {enable: true},
allowLocalhostAsSecureOrigin: true,
autoRegister: true,
notifyButton: {enable: false}
}]);
</script>
<body>
<h1>It works!</h1>
</body>
</html>
èªåã§、
Your App IDãç½®ãæã
é¨åãæ¸ãæãã¦ãã ãã。
ãã©ã¦ã¶ããæ¿èª
ã®å®è¡
http://localhost/
ã«ã¢ã¯ã»ã¹ãã¦ã¢ã¯ã»ã¹ã許å¯ããã¦ãµã¤ãã«æ»ã確èªä½æ¥
ã¨ããã¾ã§ãSafariã®è¨å®æ¬¡ã«ãã®ä»ãã©ã¦ã¶å¯¾å¿
å人çã«ã§ããå®ã¯Safariã®æ¹ãç°¡åã§ãã。
3.ãã®ä»ãã©ã¦ã¶å¯¾å¿
次ã¯ãã®ä»ãã©ã¦ã¶ä»åã®ãã¹ãã¯Chromeã§å®æ½
ãã®æ¹æ³ã§FireFoxã対å¿å¯è½ã§ã。
3-1.è¨å®æ
å ±ã®ç»é²
App Setting
=>
Google Chrome and Mozilla Firefox
=>
CONFIGURE
ã®é çªã§ç§»å
å
¥åæ
å ±ããã®å ´åã¯、
https://localhost
ã«ãã¦
My site is not fully HTTPS
è¨å®ããã§ãã¯ãã¤ããªãããã«ãã¦ç»é²ãã¾ã。
è²ã
試ããã®ã§ããããããªãã¨æ£ããç»é²ã§ããªã。
3-2.追å ãã¡ã¤ã«ã®è¨ç½®
ããã§èªè¨¼ã®åã«ä¸ã¤å¯¾å¿ãå
¥ãã¾ã。
index.html
ã®å¤æ´ã¯ä¸è¦ãªã®ã§ãã追å ã§JSãã¡ã¤ã«ãï¼ã¤å¿
è¦ã§ã。
# cd /Library/WebServer/Documents/
# sudo wget https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js
ã©ãããChromeãFireFoxã ã¨ãã¼ã«ã«å
ã®OneSignalSDKWorker.jsãå¿
è¦ã¿ããã§ãããåã£ã¦æ¥ãå¿
è¦ãããã¾ã。
ãã®å
容ã®æ³¨æãããã¨ãããããã¾ã。
ä¾ãã°ãµã¤ãã®ã¢ã¯ã»ã¹ã
http://localhost/~{ã¦ã¼ã¶å}/index.html
ãã®å ´åã§ã
OneSignalSDKWorker.js
ã®ã¢ã¯ã»ã¹å
ã¯
http://localhost/OneSignalSDKWorker.js
ã«ããå¿
è¦ãããã¨ããã§ã。
å°ãã¿ã¦ã¿ãã¨Crhomeç¨ã®ãããã°ã³ã³ã½ã¼ã«ã«åºã¦æ¥ãã®ã§å¤±æããå ´åã¯、ã¨ã©ã¼ãã°ããã§ãã¯ãã¦ã¿ãã¨è¯ãã§ã。