0
我使用Wordpress的Onesignal,其中會員可以通過單擊鏈接訂閱通知。如何更改此鏈接以顯示已註冊用戶的特定消息?OneSignal - 向已訂閱的會員顯示特定消息
這是我試過的。此代碼顯示尚未訂閱的人的訂閱鏈接。並且不顯示已經訂閱的人。我的「回聲」功能似乎不起作用
有人可以幫忙嗎?
<body>
<a href="#" id="subscribe-link" style="display: none;"></i><b> Subscribe to
notifications </b></a>
<script>
function subscribe() {
OneSignal.push(["registerForPushNotifications"]);
event.preventDefault();
}
var OneSignal = OneSignal || [];
/* This example assumes you've already initialized OneSignal */
OneSignal.push(function() {
// If we're on an unsupported browser, do nothing
if (!OneSignal.isPushNotificationsSupported()) {
return;
}
OneSignal.isPushNotificationsEnabled(function(isEnabled) {
if (isEnabled) { echo "You have already subscribed to notifications";
} else {
document.getElementById("subscribe-link").addEventListener('click', subscribe);
document.getElementById("subscribe-link").style.display = '';
}
});
});
</script>
`