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>
`