Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Browser webpush #2661

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Browser webpush #2661

wants to merge 6 commits into from

Conversation

codelius
Copy link

Make WebPush easier and more standardized for the browser platform, using same/similar registration semantics as iOS and Android. Eliminates hard-wired manifest and service worker injection as well as the hard-wired pushServiceURL logic, which made the old code unusable for real-world applications.

These changes will break apps that depend on the plugin's hard-wired manifest, service worker and pushServiceURL logic (a fix, IMHO). If this is a concern for 2.x it would be nice to see a 3.0.alpha soon.

Description

www/browser/push.js:

  • Eliminate injection of manifest.json into html head element - manifest.json should be provided by app
  • Eliminate injection of service worker - should be provided by app
  • Eliminate push service sub/unsub calls - easier to handle in app based on push.js events, just as in iOS and Android
  • Add new registrationType of value WEB_PUSH to registration event to align with iOS/Android push.js
  • Add subscription element to registration data to pass full browser push subscription dict
  • Throw original errors to make debugging easier

plugin.xml:

  • Eliminate ServiceWorker.js and manifest.json assets and after_prepare hook - should be provided by app

API.MD, EXAMPLES.md, PAYLOAD.md

  • Updated documentation in line with code changes
  • Provided more description of WebPush interaction flow

Related Issue

#2626, #1399

Motivation and Context

Makes it easier to use WebPush; eliminates obsolete boilerplate and places responsibility for sub/unsub logic in client code (as is already the case for iOS and Android).

How Has This Been Tested?

Runs in Chrome, Firefox, Edge.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

It only breaks existing functionality if anyone is using the current pushServiceURL mechanism.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant