提问人:Mohd Aqib 提问时间:10/12/2023 更新时间:10/12/2023 访问量:43
'[Worker Messenger] [Page -> SW] 无法将 ServiceWorkerRegistration 发送到 postMessage
`[Worker Messenger] [Page -> SW] Could not get ServiceWorkerRegistration to postMessage
问:
'[Worker Messenger] [Page -> SW] 无法让 ServiceWorkerRegistration 发布消息! 我在 Chrome 中收到此错误,并且相同的代码适用于 edge 最近几天没有工作 我想打印此信息 我在 Chrome 中收到此错误,并且相同的代码适用于 edge 最近几天没有工作
OneSignalSDKWorker.js
importScripts("https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js");
Index.tsx
OneSignal.init({
appId: "oneSignalAppid",
autoRegister: true,
persistNotification: true,
notificationClickHandlerMatch: "URL",
});
App.tsx
useEffect(() => {
const onNotificationClicked = function (data) {
console.log(data);
};
const handler = function (data) {
onNotificationClicked(data);
};
OneSignal.addListenerForNotificationOpened(handler);
OneSignal.getUserId().then(function (userId) {
setUserID(userId);
});
// Handle received notifications
OneSignal.on("notificationDisplay", (event) => {
console.log(event);
});
}, []);
答: 暂无答案
评论