@return {Promise }
({
image,
text,
tag,
title,
silent,
onclick,
[kZombieUrl]: zombieUrl,
[kZombieTimeout]: zombieTimeout,
}, src)
| 12 | addPublicCommands({ |
| 13 | /** @return {Promise<string>} */ |
| 14 | async Notification({ |
| 15 | image, |
| 16 | text, |
| 17 | tag, |
| 18 | title, |
| 19 | silent, |
| 20 | onclick, |
| 21 | [kZombieUrl]: zombieUrl, |
| 22 | [kZombieTimeout]: zombieTimeout, |
| 23 | }, src) { |
| 24 | if (tag) clearZombieTimer(openers[tag]); |
| 25 | const notificationId = await browser.notifications.create(tag, { |
| 26 | type: 'basic', |
| 27 | title: [title, IS_FIREFOX && i18n('extName')]::trueJoin(' - '), // Chrome already shows the name |
| 28 | message: text, |
| 29 | iconUrl: image || defaultImage, |
| 30 | ...!IS_FIREFOX && { |
| 31 | requireInteraction: !!onclick, |
| 32 | }, |
| 33 | ...CHROME >= 70 && { |
| 34 | silent, |
| 35 | } |
| 36 | }); |
| 37 | if (isFunction(onclick)) { |
| 38 | openers[notificationId] = onclick; |
| 39 | } else if (src) { |
| 40 | openers[notificationId] = src; |
| 41 | if (+zombieTimeout > 0) src[kZombieTimeout] = +zombieTimeout; |
| 42 | if (zombieUrl != null) src[kZombieUrl] = vetUrl(zombieUrl, src.url); |
| 43 | } |
| 44 | return notificationId; |
| 45 | }, |
| 46 | RemoveNotification(nid) { |
| 47 | clearZombieTimer(openers[nid]); |
| 48 | removeNotification(nid); |
nothing calls this directly
no test coverage detected