Created
February 20, 2020 13:08
-
-
Save SuryaSankar/9b35029d507923a2142a5ec68a024764 to your computer and use it in GitHub Desktop.
Webpush basic functionality - Admin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <link rel="icon" href="data:,"> | |
| <script | |
| src="https://code.jquery.com/jquery-3.4.1.min.js" | |
| integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" | |
| crossorigin="anonymous"></script> | |
| </head> | |
| <body> | |
| <h1>Trigger a Push Notification</h1> | |
| <form method="POST" id="trigger-push-form" action="/admin-api/trigger-push-notifications"> | |
| <div> | |
| <label for="title">Message Title: </label> | |
| <input name="title"/> | |
| </div> | |
| <div> | |
| <label for="body">Message Body: </label> | |
| <textarea rows="10" cols="100" name="body"></textarea> | |
| </div> | |
| <input type="submit" value="Trigger Push"> | |
| </form> | |
| <script type="text/javascript"> | |
| $(function(){ | |
| $("#trigger-push-form").submit(function(event){ | |
| event.preventDefault(); | |
| $.ajax({ | |
| type: 'POST', | |
| url: $("#trigger-push-form").attr("action"), | |
| contentType: 'application/json', | |
| processData: false, | |
| data: JSON.stringify( | |
| $("#trigger-push-form") | |
| .serializeArray() | |
| .reduce(function(result, item){ | |
| result[item.name] = item.value; | |
| return result; | |
| }, {}) | |
| ), | |
| success: function(response) { | |
| console.log("received response ", response); | |
| }, | |
| }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment