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 4

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
1 hour ago, psy said:

I'm creating a module to integrate https://pushalert.co/ into ProcessWire.

Have you checked out Foxpush? The free plan has unlimited subscribers. Maybe overall has better features than PushAlert?

  • 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

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 psy
      This module enables you to send push notifications and receive information about sent notifications on your HTTPS ProcessWire website.
      It enables you to:
      Create a field of type FieldtypePushAlert that you can add to a page template. This is a multi-input field widget that enables you to send notifications from your page in the admin Page Edit and monitor statistics - Attempted, Delivered, Clicked, etc Send notifications from a page template directly using the API, eg to PW users who have a specific role and have subscribed to notifications Capture subscriptions on your website front end All kudos to the great support team at PushAlert and to all the ProcessWire developers who've helped me with this project.
      Download from the Modules directory at: https://modules.processwire.com/modules/push-alert/
      or from GitHub at: https://github.com/clipmagic/PushAlert
      Full instructions for use are in the module README.md file.
      Enjoy!
    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: