-
+
diff --git a/README.md b/README.md index 5973915..84d43af 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ const options = { icon: "https://andreinwald.github.io/webpush-ios-example/images/favicon.png", image: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg/1920px-Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg", data: { - "url": "https://andreinwald.github.io/webpush-ios-example/success.html", + "url": "https://andreinwald.github.io/webpush-ios-example/?page=success", "message_id": "your_internal_unique_message_id_for_tracking" }, }; diff --git a/backend-sender.js b/backend-sender.js index 470ea23..78d283c 100644 --- a/backend-sender.js +++ b/backend-sender.js @@ -32,7 +32,7 @@ let pushData = JSON.stringify({ "icon": "https://andreinwald.github.io/webpush-ios-example/images/favicon.png", "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg/1920px-Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg", "data": { - "url": "https://andreinwald.github.io/webpush-ios-example/success.html", + "url": "https://andreinwald.github.io/webpush-ios-example/?page=success", "message_id": "your_internal_unique_message_id_for_tracking" } }); diff --git a/frontend.js b/frontend.js index a7ac7c7..9930346 100644 --- a/frontend.js +++ b/frontend.js @@ -1,7 +1,3 @@ -if (navigator.serviceWorker) { - initServiceWorker(); -} - async function initServiceWorker() { let swRegistration = await navigator.serviceWorker.register('https://andreinwald.github.io/webpush-ios-example/serviceworker.js', {scope: '/webpush-ios-example/'}) let pushManager = swRegistration.pushManager; @@ -78,7 +74,7 @@ function testSend() { icon: "https://andreinwald.github.io/webpush-ios-example/images/push_icon.jpg", image: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg/1920px-Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg", data: { - "url": "https://andreinwald.github.io/webpush-ios-example/success.html", + "url": "https://andreinwald.github.io/webpush-ios-example/?page=success", "message_id": "your_internal_unique_message_id_for_tracking" }, }; @@ -86,3 +82,11 @@ function testSend() { await serviceWorker.showNotification(title, options); }); } + +if ((new URLSearchParams(window.location.search)).get('page') === 'success') { + document.getElementById('content').innerHTML = 'You successfully opened page from WebPush! (this url was that was set in json data param)'; +} + +if (navigator.serviceWorker) { + initServiceWorker(); +} diff --git a/index.html b/index.html index 6426098..7e5d9a8 100644 --- a/index.html +++ b/index.html @@ -6,27 +6,40 @@ - +