You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
Suggestion of example for notification image with on-the-fly OffscreenCanvas generated image.
Details....
A code sample as a starter:
// canvas.toDataURL() not available with OffscreenCanvas ?consttoDataURL=async(data)=>newPromise(ok=>{constreader=newFileReader();reader.addEventListener('load',()=>ok(reader.result));reader.readAsDataURL(data);});constimageCanvas=async(title)=>{constcanvas=newOffscreenCanvas(192,192);constctx=canvas.getContext('2d');ctx.font="30px Comic Sans MS";ctx.fillStyle="red";ctx.textAlign="center";ctx.fillText(title,canvas.width/2,canvas.height/2);// Hack-ishconstblob=awaitcanvas.convertToBlob();returnawaittoDataURL(blob);};self.addEventListener("push",event=>event.waitUntil(Promise.resolve().then(async()=>{letbody,image;if(self.OffscreenCanvas)image=awaitimageCanvas('Hello Push');elsebody='Your Browser does not support OffscreenCanvas with Service Worker';console.log('[SW]',{ image });returnself.registration.showNotification('OffscreenCanvas Demo',{
body,
image,tag: 'canvas',});})););
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
cc @gauntface
Type of Issue
Suggestion of example for notification image with on-the-fly OffscreenCanvas generated image.
Details....
A code sample as a starter:
The text was updated successfully, but these errors were encountered: