我对 GAE 和推送 API/服务工作者很感兴趣,我正在尝试订阅 pushManager 但是,pushManager getSubscription 方法处理程序返回空引用
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration)
{ console.log('in side ready ' );
// Do we already have a push message subscription?
serviceWorkerRegistration.pushManager.getSubscription()
.then(function(subscription) {
// Enable any UI which subscribes / unsubscribes from
// push messages.
var pushButton = document.querySelector('.js-push-button');
pushButton.disabled = false;
if (!subscription) {
// We aren't subscribed to push, so set UI
// to allow the user to enable push console.log('subscription error ' );
return;
} console.log('subscriptioned ' );
// Keep your server in sync with the latest subscriptionId
sendSubscriptionToServer(subscription);
// Set your UI to show they have subscribed for
// push messages
pushButton.textContent = 'Disable Push Messages';
isPushEnabled = true;
})
.catch(function(err) {
console.warn('Error during getSubscription()', err);
}); });
然后在能够的代码getSubscription()
中将订阅值返回为空,因此,如果块和函数存在,则控制权
如果我想打电话给
serviceWorkerRegistration.pushManager.subscribe()
然后我收到以下错误
registration failed - no sender id provided
请在https://dtatable-date-filter.googleplex.com/home下方找到工作进度 url