Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome mobile support #288

Open
aleha84 opened this issue Feb 19, 2017 · 1 comment
Open

Chrome mobile support #288

aleha84 opened this issue Feb 19, 2017 · 1 comment

Comments

@aleha84
Copy link

aleha84 commented Feb 19, 2017

Chrome mobile will not show native browser notifications via new Notification(...). It uses modern Service Workers approach. Here is a link for solutions of how to show and how to detect this behavior.

@hperrin hperrin added this to the 4.0.0 milestone Apr 10, 2017
@hperrin hperrin self-assigned this Oct 3, 2017
@hperrin hperrin removed their assignment Oct 3, 2017
@ashrafsabrym
Copy link

Please be aware that Chrome on Android won't support desktop notifications through new Notification(…). See this issue and that one.
This issue should be marked as a bug because pNotify desktop module will fail on that platform.
Using ServiceWorker notifications is out of the scope of pNotify, so the solution should be, like some contributors noted, trying creating a Notification object first and catching the exception if any:

function isNewNotificationSupported() {
    if (!window.Notification || !Notification.requestPermission)
        return false;
    if (Notification.permission == 'granted')
        throw new Error('You must only call this *before* calling Notification.requestPermission(), otherwise this feature detect would bug the user with an actual notification!');
    try {
        new Notification('');
    } catch (e) {
        if (e.name == 'TypeError')
            return false;
    }
    return true;
}

This code should be used in Component.permission in PNotifyDesktop.html

This issue is related too #289

@hperrin hperrin modified the milestones: 4.0.0, 4.1.0 Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants