Bug 247315 - `'Notification' in window` returns false
Summary: `'Notification' in window` returns false
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 16
Hardware: iPhone / iPad iOS 16
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-11-01 06:43 PDT by N
Modified: 2024-02-04 11:35 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description N 2022-11-01 06:43:30 PDT
Hey
I have iOS 16.2 installed on my iPhone, and I have enabled under Safari's experimental WebKit features:

- Built-in Web Notifications
- Push API
- Permissions API

However, while `'PushManager' in window` returns true, `'Notification' in window` returns false, so I can't use the very basic `Notification.permission` so I can handle the modals and requests properly.

Do you know if it will be the case that Safari won't be supporting such basic and important thing as `Notification.permission` ?

Thank you!
Comment 1 Alexey Proskuryakov 2022-11-01 12:49:57 PDT
Notification.permission is certainly supported, and exposed as window.Notification.permission. CC'ing some folks who would know why the "in window" check fails.
Comment 2 N 2022-11-01 14:54:24 PDT
Thanks Alexey.

I've just tested "window.Notification", and it seems to be "undefined".

I double checked, and I have those same 3 feature flags (listed in my previous comment) enabled.
Comment 3 Brady Eidson 2022-11-03 13:19:45 PDT
No matter what you've done with those experimental feature flags, window.Notification is not supported in Safari on iOS 16.

As for your questions of when Safari will support a particular feature; Safari is a product shipped by Apple, not the WebKit open source project.

So this is not a place where that can be answered.
Comment 4 Alexey Proskuryakov 2022-11-03 13:26:08 PDT
I tested wrong. First, I tested on macOS. Second, I tried `Notification in window` instead of `'Notification' in window`. Embarrassing.
Comment 5 N 2022-11-03 14:30:57 PDT
Thanks Brady.

Could you please indicate where can I report this and get answers about this?

This looks like a significant hole on the implementation of Web Push, as we need to know the value of `Notification.permission` to be able to optimize the user's experience on the website.

(and avoid annoying the user, or provide the user with instructions to unblock the notifications if they are trying to turn these on again, etc)
Comment 6 Radar WebKit Bug Importer 2022-11-08 05:44:19 PST
<rdar://problem/102087326>
Comment 7 Brady Eidson 2023-05-23 15:54:57 PDT
(In reply to N from comment #5)
> Thanks Brady.
> 
> Could you please indicate where can I report this and get answers about this?
> 
> This looks like a significant hole on the implementation of Web Push, as we
> need to know the value of `Notification.permission` to be able to optimize
> the user's experience on the website.
> 
> (and avoid annoying the user, or provide the user with instructions to
> unblock the notifications if they are trying to turn these on again, etc)

Can you use navigator.permissions for that?

There's a code snippet here:
https://webkit.org/blog/14112/badging-for-home-screen-web-apps/
Comment 8 William J. Edney 2024-02-04 11:35:57 PST
In case anyone else happens upon this bug, in Safari for iOS (at least as of iOS 17.3), the Notification object is undefined (i.e. "'Notification' in window" will fail) *unless the page is "installed"* (i.e. it is running as a PWA / has been "Add(ed) To Home Screen").