Jump to content
psy

Push notifications for PW

Recommended Posts

Background

I'm creating a module to integrate https://pushalert.co/ into ProcessWire. You actually don't even need a module. You could just use the "Other Websites" javascript provided by PushAlert for basic functionality, ie send a broadcast notification to all subscribers. This is essentially what all the other integrations, including WordPress, do. The WP integration installs a widget with a form enabling the admin to enter details such as title, message, etc from a blog post. It does not:

  • collect any statistics within the CMS about the notification
  • enable audience fine tuning to eg a particular subscriber or subscriber segment within WP. The admin needs to use the PA dashboard for that functionality

PushAlert has a javascript and REST API. It's intended that this module will use both. https://pushalert.co/documentation 

What my module does so far:

  • associate a subscription with a user. FE user clicks a button on the website front end to subscribe and/or agrees to the browser popup to accept notifications from this site
  • send broadcast push alerts from a page within admin

It doesn't have a 'widget' but easy enough to create a fieldsetpage with the relevant fields and add that fs page to any appropriate templates, then with a hook, send the notification. Need to be careful that once published/sent, the notification is not automatically re-sent on subsequent page edits.

Looking for help/collaboration on how best:

  • to send a notification, eg from a blog post, then track the statistics. Dilemma is that the push notification must come from the admin page. Responses go to the sending page which, as it's an admin page, is restricted and will not accept the https response. This is where the other CMS integrations stop. The only json response from PushAlert is the status, eg 'success', and the notification id. There is no opportunity at this point to capture the sending page id.
  • handle, 'once sent on page publish', do not automatically resend on future page edits

Am thinking along the lines that FS Page will have a @kongondo runtime markup field https://modules.processwire.com/modules/fieldtype-runtime-markup/ to pull the stats from PushAlert. Every time an admin visits the page, the stats will update.

Once an admin checks the 'Send notification on page publish' checkbox, a hook creates new front end page that records the 'sender page', sends the notification request to PA, which then uses that newly created frontend page, as the response endpoint. Another rook re-associates the front end page with the admin page (eg blog post), to update the stats.

Potential use cases:

Notify individual and/or users with a particular role of an event, eg "New work opportunity" for job seekers; new blog post published; entries now open, etc...

Looking for help/ideas/collaboration on this module. Please let me know if you're interested and as I do, believe this would be a great addition to ProcessWire

 

 

 

 

 

 

 

 

  • Like 5

Share this post


Link to post
Share on other sites

I am generally interested, but I'm wondering: What's the advantage of using a service such as pushalert.co?

Apparently there is a PHP library you could use: https://github.com/web-push-libs/web-push-php/blob/master/README.md

I'm guessing the hard part about the whole setup is to create server keys?

Guess I have to dig deeper into this whole topic...

  • Like 1

Share this post


Link to post
Share on other sites

I've made some development using OneSignal's API which has the caveat that if you use their free service they can use your data for their purposes.  

For the 'once sent on page publish' issue, I just put a checkbox on the pages that enable notifications and check them if I wan to actually send the notification. 

Why would you not be able to get the response? I don't remember having any trouble getting responses from the OneSignal API, all code ran through a hook in ProcessPageEdit. I then saved the response data and basically just checked on page load for the notification info with its ID, I see push alert has a similar API.   (if it had been completed, and how many had received it,failed, clicked). 

4 hours ago, dragan said:

I am generally interested, but I'm wondering: What's the advantage of using a service such as pushalert.co?

 

In my case, I thought the API was really nice and offered an easy way to manage mulitple websites straight from the API. (that way i handle multiple website's notifications from one place) . Also the Js to actually display subscription buttons info frontend or call their API in an easier fashion from a custom button. I even configured some color fields and text fields in PW to customize every text/color that rendered from their Js UI passing a customization object.  Also didn't have to build any reporting stuff which for my case, wasn't necessary.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you @dragan @PWaddict and @elabx for your detailed and considered opinions. Much appreciated.

I investigated all your suggestions and all of you asked why I chose PushAlert. Simple really, it was the first I found some time last year. I searched for others but none of the solutions you presented came up. PushAlert seemed to have the best plans and I've found their tech support to be responsive and helpful.

OneSignal appears to be the biggest and has the most fully documented solutions. However, like @elabx, I was uncomfortable with the fact that you had to pay for GDPR security??? The leap from free to US$99/mo for what should be a right not a privilege didn't sit well with me. I guess they make their money from selling the marketing data rather from their sender clients?

Ended up going back to PushAlerts and they have a published GDPR Compliance page covering all plans, including free. https://pushalert.co/gdpr On the flip side, you don't get the detailed reporting but then I doubt 99.9% of clients would want it. They want to know how many notifications were sent, how many were successfully received, how many CTA's clicked and how many unsubscribed. All this info is provided by PushAlert while still protecting subscriber confidentiality. Works for me! 

@elabx would you consider sharing your code with me? Why reinvent the wheel and your ideas are exactly what I'm looking for to adapt to PushAlert.

Thanks again

  • Like 1

Share this post


Link to post
Share on other sites

Will push notifications cause trouble on shared hosting websites if all sent at once? Maybe an option would be great to send notifications for example in batch of 50 per x minutes?

Share this post


Link to post
Share on other sites
2 hours ago, PWaddict said:

Will push notifications cause trouble on shared hosting websites if all sent at once? Maybe an option would be great to send notifications for example in batch of 50 per x minutes?

Yes, absolutely - same as sending email campaigns directly from the website vs going with an email-sending provider such as CampaignMonitor or MailChimp. This is a key decider for going with a notification-sending provider

 

  • Like 1

Share this post


Link to post
Share on other sites

PushAlert4PW WIP.... Some more on the PushAlert REST API.

Every sent alert requires a URL and it appears in the notification. Silly me thought that was 'just life'. Didn't realise until I chatted with Alex from PushAlert, that it is in fact the URL to which notification responses are sent. It does not have to be the page, eg an admin page, that sent the push notification. So cool!

The URL also appears in the notifications so thinking about hooking into the front end home page URL to capture the json responses and save the data to a different page that connects the sending page with the message id. Onward & upward

 

  • Like 3

Share this post


Link to post
Share on other sites

Module starting to come together. Will of course give credit to other devs whose module code I've studied and in some cases, unashamedly copied, including @elabx draft OnSignal and nico's MarkupSEO. Ready now to jump

 

 

  • Haha 3

Share this post


Link to post
Share on other sites
19 hours ago, PWaddict said:

@elabx Can you please write a tutorial with the related code on how to implement OneSignal with PW?

I'll try to find time to write a simplified version of the module and share it here. (because the module I wrote is  a bit quite messy code wise).

  • Like 1

Share this post


Link to post
Share on other sites

Quick update

Please (whatever deity you choose), I'm close to publishing an alpha version. The PushAlert API is easy. It's the PW integration that challenged me. If you only ever want to capture subscriptions to PushAlert and send notifications carte-blanche via a PW template without capturing stats, and/or sending advanced options, eg to a specific user instead of everybody, the instructions in the PushAlert docs will get you going.

This module is more than just a wrapper...  more soon including the readme.md (why does that always come last?)

Anyone interested in being a guinea pig tester?

  • Like 2

Share this post


Link to post
Share on other sites

Hi, I'm thinking to implement your solution for a couple of primary school websites (they would comfortably fit into the free plan).
I can see the module requires a separate title and message field for templates.
 

Is it not possible to just use the existing title/headline and summary/body fields for the message purpose? 

My purpose would be to provide parents to possibility to get notified each time a news article is published on the website.
Thanks for the great work!

Share this post


Link to post
Share on other sites

Hi @Jozsef

The module defines a special fieldtype of FieldtypePushAlert - this generates the message title, content etc sub-fields in the template for the push notification. It's used in various ways under the hood to send and gather/display stats about the notification. So, no, you can't use the existing title, headline, summary fields with this module.

Share this post


Link to post
Share on other sites

Thanks, @psy, it sure offers more flexibility. I'll play around if I can use hooks to manipulate these fields on save when I get a little time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      Process Cache Control
      This module provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Clear the ProCache page render cache (if your site is using ProCache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Plans for improvements
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory CHANGELOG in the repository Screenshots


    • By Macrura
      PrevNextTabs Module
      Github: https://github.com/outflux3/PrevNextTabs
      Processwire helper modules for adding page navigation within the editor.
      Overview
      This is a very simple module that adds Previous and Next links inline with the tabs on the page editor. Hovering over the tab shows the title of the previous or next page (using the admin's built in jqueryUI tooltips.)
      Usage
      This module is typically used during development where you or your editors need to traverse through pages for the purpose of proofing, flagging and/or commenting. Rather than returning to the page tree or lister, they can navigate with these links.
      Warnings
      If you are using PW version 2.6.1 or later, the system will prevent you from leaving the page if you have unsaved edits.
      For earlier versions, to avoid accidentally losing changes made to a page that might occur if a user accidentally clicks on one of these, make sure to have the Form Save Reminder module installed.
      http://modules.processwire.com/modules/prev-next-tabs/
    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.2.0
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
      There is a new Version in the pipe, that supports WebP too: 
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
       
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
×
×
  • Create New...