如何在Chrome GCM推送通知的通知中显示日期时间

时间:2015-09-28 11:12:30

标签: google-cloud-messaging chrome-gcm web-push push-api

我想在Chrome GCM推送通知的通知中列出更多数据,如日期,时间。如我的代码所示:

self.addEventListener('push', function(event) {
    console.log('Received a push message from local', event);

    var title = 'My title file. Testing on';
    var body = 'New Push Message.';
    var icon = 'refresh_blueicon.png';
    var tag = 'my-push-tag';

    event.waitUntil(fetch('http://localhost/pushMsg/Push_Notification/msg.php').then(function(response) {
        if (response.status !== 200) {
            console.log('Looks like there was a problem. Status Code: ' + response.status);
            throw new Error();
        }

        // Examine the text in the response
        return response.json().then(function(data) {
            self.registration.showNotification(data.title, {
                body: data.msg,
                icon: icon,
                tag: tag
            }) // here i want to add more, need to know what is possible to add
        })
    })
);

如何在此通知窗口中添加日期和时间?这是一个例子:

enter image description here

0 个答案:

没有答案
相关问题