From 19424729a3716e9fdcfc64e010d54b72de72b67c Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Thu, 23 Nov 2017 09:52:45 +0900
Subject: [PATCH] :v:

---
 src/web/app/common/mios.ts | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts
index dfc83c18c6..6ee42ea8a7 100644
--- a/src/web/app/common/mios.ts
+++ b/src/web/app/common/mios.ts
@@ -257,11 +257,17 @@ export default class MiOS extends EventEmitter {
 					auth: encode(subscription.getKey('auth')),
 					publickey: encode(subscription.getKey('p256dh'))
 				});
-			}).then(() => {
-				this.logInfo('[sw] Server Stored Subscription.');
-			}).catch(async (err) => {
+			})
+			// When subscribe failed
+			.catch(async (err: Error) => {
 				this.logError('[sw] Subscribe Error:', err);
 
+				// 通知が許可されていなかったとき
+				if (err.name == 'NotAllowedError') {
+					this.logError('[sw] Subscribe failed due to notification not allowed');
+					return;
+				}
+
 				// 違うapplicationServerKey (または gcm_sender_id)のサブスクリプションが
 				// 既に存在していることが原因でエラーになった可能性があるので、
 				// そのサブスクリプションを解除しておく