@@ -392,14 +392,26 @@ <h3>
392
392
</ dd >
393
393
</ dl >
394
394
</ dd >
395
+ < dt >
396
+ < code > app_badge</ code >
397
+ </ dt >
398
+ < dd >
399
+ < p >
400
+ A [=/64-bit unsigned integer=].
401
+ </ p >
402
+ < p class ="note ">
403
+ Platform conventions are likely to impose a lower limit with regards to what is
404
+ displayed to the end user. [[BADGING]]
405
+ </ p >
406
+ </ dd >
395
407
< dt >
396
408
< code > mutable</ code >
397
409
</ dt >
398
410
< dd >
399
411
< p >
400
412
A boolean. When true causes a < code > push</ code > event to be dispatched to a service
401
- worker (if any) containing the {{Notification}} object described by the
402
- < a > declarative push message</ a > .
413
+ worker (if any) containing the {{Notification}} object and app badge number (if
414
+ any) described by the < a > declarative push message</ a > .
403
415
</ p >
404
416
</ dd >
405
417
</ dl >
411
423
< p >
412
424
A < dfn > declarative push message parser result</ dfn > is a [=/tuple=] consisting of a
413
425
< dfn data-dfn-for ="declarative push message parser result "> notification</ dfn > (a
414
- [=/notification=]) and a < dfn data-dfn-for =
426
+ [=/notification=]), an < dfn data-dfn-for ="declarative push message parser result "> app
427
+ badge</ dfn > (null or an integer), and a < dfn data-dfn-for =
415
428
"declarative push message parser result "> mutable</ dfn > (a boolean).
416
429
</ p >
417
430
< p >
@@ -673,6 +686,18 @@ <h3>
673
686
< var > notification</ var > 's [=notification/actions=] is null, then return failure.
674
687
</ p >
675
688
</ li >
689
+ < li >
690
+ < p >
691
+ Let < var > appBadge</ var > be null.
692
+ </ p >
693
+ </ li >
694
+ < li >
695
+ < p >
696
+ If < var > message</ var > ["`app_badge`"] [=map/exists=] and
697
+ < var > message</ var > ["`app_badge`"] is a [=/64-bit unsigned integer=], then set
698
+ < var > appBadge</ var > to < var > message</ var > ["`app_badge`"].
699
+ </ p > <!-- unsigned long long in Web IDL -->
700
+ </ li >
676
701
< li >
677
702
< p >
678
703
Let < var > mutable</ var > be false.
687
712
</ li >
688
713
< li >
689
714
< p >
690
- Return (< var > notification</ var > , < var > mutable</ var > ).
715
+ Return (< var > notification</ var > , < var > appBadge </ var > , < var > mutable</ var > ).
691
716
</ p >
692
717
</ li >
693
718
</ ol >
@@ -1598,11 +1623,13 @@ <h2>
1598
1623
constructor(DOMString type, optional PushEventInit eventInitDict = {});
1599
1624
readonly attribute PushMessageData? data;
1600
1625
readonly attribute Notification? notification;
1626
+ readonly attribute unsigned long long? appBadge;
1601
1627
};
1602
1628
1603
1629
dictionary PushEventInit : ExtendableEventInit {
1604
1630
PushMessageDataInit? data = null;
1605
1631
Notification? notification = null;
1632
+ unsigned long long? appBadge = null;
1606
1633
};
1607
1634
1608
1635
typedef (BufferSource or USVString) PushMessageDataInit;
@@ -1629,6 +1656,9 @@ <h2>
1629
1656
< p >
1630
1657
The < dfn > notification</ dfn > attribute must return the value it was initialized with.
1631
1658
</ p >
1659
+ < p >
1660
+ The < dfn > appBadge</ dfn > attribute must return the value it was initialized with.
1661
+ </ p >
1632
1662
</ section >
1633
1663
< section >
1634
1664
< h2 >
@@ -1715,6 +1745,11 @@ <h2>
1715
1745
Let |notificationShown| be false.
1716
1746
</ p >
1717
1747
</ li >
1748
+ < li >
1749
+ < p >
1750
+ Let |appBadgeSet| be false.
1751
+ </ p >
1752
+ </ li >
1718
1753
< li >
1719
1754
< p >
1720
1755
If |declarativeResult|'s [=declarative push message parser result/mutable=]
@@ -1724,14 +1759,16 @@ <h2>
1724
1759
< li >
1725
1760
< p >
1726
1761
Let |result| be the result of [=fire a push event|firing a push event=]
1727
- given |registration|, null, and a new {{Notification}} object
1728
- representing |notification|.
1762
+ given |registration|, null, a new {{Notification}} object representing
1763
+ |notification|, and |declarativeResult|'s [=declarative push message
1764
+ parser result/app badge=].
1729
1765
</ p >
1730
1766
</ li >
1731
1767
< li >
1732
1768
< p >
1733
1769
If |result| is not failure, then set |notificationShown| to |result|'s
1734
- [=push event result/notification shown=].
1770
+ [=push event result/notification shown=] and |appBadgeSet| to |result|'s
1771
+ [=push event result/app badge set=].
1735
1772
</ p >
1736
1773
</ li >
1737
1774
</ ol >
@@ -1742,6 +1779,12 @@ <h2>
1742
1779
given |notification|.
1743
1780
</ p >
1744
1781
</ li >
1782
+ < li >
1783
+ < p >
1784
+ If |appBadgeSet| is false, then < a href =
1785
+ "https://github.com/w3c/badging/issues/111 "> w3c/badging #111</ a > ...
1786
+ </ p >
1787
+ </ li >
1745
1788
< li >
1746
1789
< p >
1747
1790
[=acknowledge a push message|Acknowledge=] the < a > push message</ a > and abort
@@ -1761,7 +1804,7 @@ <h2>
1761
1804
< li >
1762
1805
< p >
1763
1806
Let |result| be the result of [=fire a push event|firing a push event=] given
1764
- |registration|, |data|, and null.
1807
+ |registration|, |data|, null, and null.
1765
1808
</ p >
1766
1809
</ li >
1767
1810
< li >
@@ -1779,20 +1822,27 @@ <h2>
1779
1822
</ li >
1780
1823
</ ol >
1781
1824
< p >
1782
- A < dfn > push event result</ dfn > is a [=/tuple=] consisting of a < dfn data-dfn-for =
1783
- "push event result "> notification shown</ dfn > (a [=/boolean=]).
1825
+ A < dfn > push event result</ dfn > is a [=/tuple=] consisting of a < dfn for =
1826
+ "push event result "> notification shown</ dfn > (a [=/boolean=]) and an < dfn for =
1827
+ "push event result "> app badge set</ dfn > (a [=/boolean=]).
1784
1828
</ p >
1785
1829
< p >
1786
1830
To < dfn > fire a push event</ dfn > given a [=/service worker registration=] |registration|,
1787
- {{PushMessageData}} object or null |data|, and a [=/notification=] or null
1788
- |notification|, run these steps. They return failure or a [=/push event result=].
1831
+ {{PushMessageData}} object or null |data|, a [=/notification=] or null |notification|,
1832
+ and an integer or null |appBadge|, run these steps. They return failure or a [=/push
1833
+ event result=].
1789
1834
</ p >
1790
1835
< ol >
1791
1836
< li >
1792
1837
< p >
1793
1838
Let |notificationResult| be null.
1794
1839
</ p >
1795
1840
</ li >
1841
+ < li >
1842
+ < p >
1843
+ Let |appBadgeResult| be null.
1844
+ </ p >
1845
+ </ li >
1796
1846
< li >
1797
1847
< p >
1798
1848
Set |registration|'s [=service worker registration/has shownotification() been
@@ -1817,6 +1867,12 @@ <h2>
1817
1867
< dd >
1818
1868
|notification|
1819
1869
</ dd >
1870
+ < dt >
1871
+ {{PushEvent/appBadge}}
1872
+ </ dt >
1873
+ < dd >
1874
+ |appBadge|
1875
+ </ dd >
1820
1876
</ dl >
1821
1877
< p >
1822
1878
Then run the following steps in parallel, with |dispatchedEvent|:
@@ -1830,21 +1886,28 @@ <h2>
1830
1886
</ li >
1831
1887
< li >
1832
1888
< p >
1833
- If they do not resolve successfully, then set |notificationResult| to failure.
1889
+ If they do not resolve successfully, then set |notificationResult| and
1890
+ |appBadgeResult| to failure and abort these steps.
1891
+ </ p >
1892
+ </ li >
1893
+ < li >
1894
+ < p >
1895
+ Set |notificationResult| to |registration|'s [=service worker registration/has
1896
+ shownotification() been successfully invoked|has `showNotification()` been
1897
+ successfully invoked=].
1834
1898
</ p >
1835
1899
</ li >
1836
1900
< li >
1837
1901
< p >
1838
- Otherwise, set |notificationResult| to |registration|'s [=service worker
1839
- registration/has shownotification() been successfully invoked|has
1840
- `showNotification()` been successfully invoked=].
1902
+ Set |appBadgeResult| to true if {{NavigatorBadge/setAppBadge()}} has been
1903
+ invoked; otherwise false.
1841
1904
</ p >
1842
1905
</ li >
1843
1906
</ ol >
1844
1907
</ li >
1845
1908
< li >
1846
1909
< p >
1847
- Wait for |notificationResult| to be non-null.
1910
+ Wait for |notificationResult| and |appBadgeResult| to be non-null.
1848
1911
</ p >
1849
1912
</ li >
1850
1913
< li >
@@ -1854,12 +1917,12 @@ <h2>
1854
1917
</ li >
1855
1918
< li >
1856
1919
< p >
1857
- [=/Assert=]: |notificationResult| is a [=/boolean =].
1920
+ [=/Assert=]: |notificationResult| and |appBadgeResult| are [=/booleans =].
1858
1921
</ p >
1859
1922
</ li >
1860
1923
< li >
1861
1924
< p >
1862
- Return (|notificationResult|).
1925
+ Return (|notificationResult|, |appBadgeResult| ).
1863
1926
</ p >
1864
1927
</ li >
1865
1928
</ ol >
0 commit comments