navigator.push is coming undefined in mozilla web IDE

RESOLVED WORKSFORME

Status

Firefox OS
Simulator
RESOLVED WORKSFORME
2 years ago
2 years ago

People

(Reporter: Parthsarthi.Sharma, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 years ago
I am using 2.2 mozilla OS simulator for push notification. When i am going to register APP with OS , its saying Push Notifications are not supported. while debugging its found that navigator.push is coming as undefined. Following is the sample code snippet.

var registerPush = document.querySelector('#register-push');

if (registerPush) {
    registerPush.onclick = function () {
        if (!navigator.push)
            return alert('Push notifications are not supported !');

        var request = navigator.push.register();

        request.onsuccess = function () {
            console.log(request.result);
        }

        request.onerror = function () {
            alert('Error getting a new endpoint !');
        }
    }
}

Updated

2 years ago
Group: b2g-core-security
Did you add the push permission to your app manifest?  See the push docs[1].

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Simple_Push_API#1._Add_push_configuration_to_the_app%27s_manifest_file
Flags: needinfo?(Parthsarthi.Sharma)
(Reporter)

Comment 2

2 years ago
hi ryan ,

thank you very much , i added these permissions and resolved the issue.

Thanks alot.
Flags: needinfo?(Parthsarthi.Sharma)
Sounds like this is resolved as of comment 2.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.