javascript - Push Notification Custom Save Browser id in Database
hi i am newbie to php and javascript and i am working on a project of Push Notification for my website which will push a notification to the user when a news related to specific category is published on my website i am using following code and curl with the help of google documentation
<html>
<head>
<title>Push Notification codelab</title>
<link rel="manifest" href="manifest.json">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<h1>Push Notification codelab</h1>
<p>This page must be accessed using HTTPS or via localhost.</p>
<script src="js/main.js"></script>
<button id="send">Send</button>
<script>
$("#send").click(function() {
$.get("curl.php", function(data) {
console.log(data);
});
});
</script>
</body>
</html>
now i am wondering how to store a user's browser id or something so that it can send a notification to specific browser for specific category news.i am really looking forward to you guys to help me out for this problem.
Answer
Solution:
there is nothing so-called as browser id, but you can generate a unique and store that in the
_COOKIE
, best combination of creating an unique id would beMD5(USER_AGENT . SALTMIX_STR . IPADDR)
, this combination will generate a unique id for each browser and you can store that in cookie usingPHP
eg.$_COOKIE["BROWSER_KEY"] = 'YOUR_UNIQUE_KEY'
EXAMPLE