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

Browser webpush #1

Merged
merged 3 commits into from
Dec 25, 2018
Merged

Browser webpush #1

merged 3 commits into from
Dec 25, 2018

Conversation

codelius
Copy link
Owner

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 pushServiceURL logic, which made the old code unusable for real-world applications.

These changes will break apps that depend on the 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

phonegap#2626, phonegap#1399

Motivation and Context

Makes it easier to use WebPush; eliminates obsolete boilerplate and places responsibility for upstream sub/unsub 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.

@codelius codelius merged commit 0c693a7 into master Dec 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant