Is there a way in one signal web-push-sdk to add user manually and unsubscribe?
I tried this in my subscribeOneSignal()
function but nothing happening.
OneSignal.push(function() {
OneSignal.registerForPushNotifications();
});
I have simple html page where I have two buttons one "Subscribe" and other is "Unsubscribe", now when user click on Subscribe button he should add at one signal and when he clicked on "Unsubscribe" button he shouldn't receive the notifications.
<!DOCTYPE html>
<html>
<head>
<link rel="manifest" href="/manifest.json">
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
<script>
var OneSignal = window.OneSignal || [];
OneSignal.push(["init", {
appId: "345345-asdf-345",
autoRegister: false,
notifyButton: {
enable: true
}
}]);
function subscribeOneSignal(){
OneSignal.push(function() {
OneSignal.registerForPushNotifications();
});
OneSignal.push(function() {
OneSignal.registerForPushNotifications({
modalPrompt: true
});
});
}
function unSubscribeOneSignal(){
//unsubscribe functionality goes here
}
</script>
</head>
<body>
<p>OneSingle Testing</p>
<br>
<button onclick="subscribeOneSignal()">Subscribe </button>
<button onclick="unSubscribeOneSignal()">Unsubscribe </button>
</body>
</html>
Nice, but I have used it, but it want users to be registered after they login to my site with their emailadress as tag:
THis works sometimes with tags and sometimes without tags. How to make it work that i will only register with email
Here is solution, It may help someone else.