我可以像 facebook 一样使用 php mysql ajax 向 opera 移动浏览器发送推送通知吗

问题描述 投票:0回答:1

我正在使用这个代码,它只有桌面浏览器,当我仍然是这个页面时,我想远程访问浏览器。

我想像 hiw facebook 发送一样向 Opera 移动浏览器发送推送通知。请帮助我

enter image description here 建议我 javascript php mysql 代码



<script>
function pushNotify() {
    if (!("Notification" in window)) {
        alert("Web browser does not support desktop notification");
    }
    if (Notification.permission !== "granted")
        Notification.requestPermission();
    else {
        $.ajax({
        url : "push-notify.php",
        type: "POST",
        success: function(data, textStatus, jqXHR) {
            // if PHP call returns data process it and show notification
            // if nothing returns then it means no notification available for now
            if ($.trim(data)){
                var data = jQuery.parseJSON(data);
                console.log(data);
                notification = createNotification( data.title,  data.icon,  data.body, data.url);
                setTimeout(function() {
                    notification.close();
                }, 5000);
            }
        },
        error: function(jqXHR, textStatus, errorThrown) {}
        });
    }
};

function createNotification(title, icon, body, url) {
    var notification = new Notification(title, {
        icon: icon,
        body: body,
    });
    notification.onclick = function() {
        window.open(url);
    };
    return notification;
}
</script>
php mysql ajax notifications push
1个回答
0
投票

是的,您可以使用 PHP 发送推送通知 但是你必须使用像爱出风头的

Mobile Push Messaging system
,OneSignal ... 或 Firebase Cloud Messaging (FCM) 我已经用过
firebase
pushy
它们很容易使用

这是我已经使用过的 PHP 的一些教程/文档

© www.soinside.com 2019 - 2024. All rights reserved.