From f958dbf967b5894c3bfba4fa7709182ef253319a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 3 Sep 2025 10:58:56 +1000 Subject: [PATCH] Add 'set the application badge for installed web application' algo --- index.html | 94 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index 64d88a8..1b654c3 100644 --- a/index.html +++ b/index.html @@ -101,7 +101,7 @@

On some operating systems [=badge/setting=] a badge can require - permission from the user. In this case, a developer need to query the + permission from the user. In this case, a developer needs to query the "[=notifications=]" permissions status before [=badge/setting=] a badge. If the permission is not granted, the developer will need to prompt for permission via the @@ -267,6 +267,34 @@

Setting the application badge

+

+ To set badge value given a [=badge=] |badge| and an optional + {{unsigned long long}} |contents| value: +

+
    +
  1. Switching on |contents|, if it happens to be the case that: +
    +
    + |contents| was not passed: +
    +
    + [=badge/Set=] |badge| to [=badge/"flag"=]. +
    +
    + |contents| is 0: +
    +
    + [=badge/Set=] |badge| to [=badge/"nothing"=]. +
    +
    + |contents|: +
    +
    + [=badge/Set=] |badge| to |contents|. +
    +
    +
  2. +

To set the application badge of platform object |context:platform object| to an optional {{unsigned long long}} @@ -306,27 +334,10 @@

-
  • Switching on |contents|, if it happens to be the case that: -
    -
    - |contents| was not passed: -
    -
    - [=badge/Set=] |badge| to [=badge/"flag"=]. -
    -
    - |contents| is 0: -
    -
    - [=badge/Set=] |badge| to [=badge/"nothing"=]. -
    -
    - |contents|: -
    -
    - [=badge/Set=] |badge| to |contents|. -
    -
    +
  • Let |badge| be the [=installed web application=]'s associated + [=badge=]. +
  • +
  • [=Set badge value=] given |badge| and |contents|.
  • [=Queue a global task=] on the [=DOM manipulation task source=] given |global| to [=resolve=] |promise| with `undefined`. @@ -336,6 +347,45 @@

  • Return |promise|.
  • +

    + To set the application badge for an installed web + application given a URL |appId| and either a {{boolean}} or + {{unsigned long long}} |contents| value. It returns a boolean + indicating whether the operation was successful: +

    +
      +
    1. Let |app| be the [=installed web application=] identified by + |appId|. +
    2. +
    3. If no such [=installed web application=] exists, return false. +
    4. +
    5. Let |badge| be |app|'s associated [=badge=]. +
    6. +
    7. [=In parallel=]: +
      +
      + |contents| is `true`: +
      +
      + [=badge/Set=] |badge| to [=badge/"flag"=]. +
      +
      + |contents| is `false` or 0: +
      +
      + [=badge/Set=] |badge| to [=badge/"nothing"=]. +
      +
      + Otherwise: +
      +
      + [=badge/Set=] |badge| to |contents|. +
      +
      +
    8. +
    9. Return true. +
    10. +