recursive.codes


The Personal Blog of Todd Sharp

Sending Push Notifications from Oracle Notification Service with Oracle Functions and Pushover

Posted By: Todd Sharp on 4/6/2021 1:00 GMT
Tagged: Cloud, Cloud, JavaScript, JavaScript

The Oracle Notification Service is an extraordinary service. I’ve blogged about it in the past (see the Complete Guide to the Oracle Notification Service), but there’s one piece of the puzzle missing today: push notifications. I’m sure some day this will be rectified, but until then I decided to tackle the issue with a third-party solution. In this post, I’ll show you how to send push notifications to a mobile device from Oracle Notification Service via Oracle Functions and Pushover.

Before you get started, head over to Pushover and sign up for a free account. All set? Great, let’s get started!

Here's a quick table of contents for easy navigation:

Create Pushover App

The first step is to create an application on Pushover. When you’re logged in, scroll down to ‘Your Applications’ and click on ‘Create an Applciation/API Token’.

Give it a name and description (and an icon, if you want) and click ‘Create Application’.

Icon: Push Notification by Federica Sala from the Noun Project

Next, copy the new application’s API key and save it locally.

Now you’ll need to download and install the Pushover app on mobile.  You can find it in your favorite App Store. When you’ve installed it, you’ll receive a “user key”. Copy  this key to your local machine as well.

Create A Serverless Application

Now we’ll create a simple serverless application with Oracle Functions that will handle sending the push notification. Using the fn CLI, create a new application.

Before you get started, it's a good idea to always make sure you're running the latest version of the fn CLI. Check what the latest release is on GitHub, then check your version with:

If you're not running the latest, you can update with:

Or, download and install the latest binary from GitHub.

Create Application

Create Function

Right. Next, create a serverless function. I’m using Node.JS here for simplicity, but this code easily be a Java or Python app - whatever you’re comfortable with!

Set Application Config Vars

We need to set our Application and User keys into the serverless config so that we can access them from our function later on.

Populate Function

Before we edit the function, modify package.json to include the dependency on the pushover library.

Now edit func.js to send the notification.

Deploy the Function

Deploy the function with:

Testing the Function

Before we integrate with ONS, let’s test out the function invocation and make sure it sends the notification.

As you can see, I received a push notification on my mobile device.

Clicking on the notification takes me to a detailed view.

 

Heads Up! Pushover has a ton of support for various languages. Checkout the list of libraries available and use the one that matches your favorite language!

Create a Subscription in ONS

Now it’s just a matter of creating a subscription in ONS that will invoke the function when a message is received.

Click on ‘Publish Message’ to test it out.

The push notification will be received just as it was when we manually invoked the function!

Summary

In this post, we looked at how to send push notifications from Oracle Notification Service via Oracle Functions with Pushover. If you have any questions or would like to see something else covered here on the developer blog, leave a comment below!

If you'd like to learn more about notifications, check out the following links.

Image by mohamed Hassan from Pixabay 



Related Posts

Adding Tracing to Your Distributed Cloud Native Microservices

Adding Tracing to Your Distributed Cloud Native Microservices

When adopting cloud-native technologies and certain architectures such as the microservice pattern, observability and monitoring become a huge need and...

Project GreenThumb Part 5 - The Front-End, Build Pipeline, Push Notifications and Overall Progress

Project GreenThumb Part 5 - The Front-End, Build Pipeline, Push Notifications and Overall Progress

In this short blog series, I introduced you to Project GreenThumb, a project that I created to automate and monitor the process of growing seedlings with...

Collect and Analyze Application and Server Metric Data with Micronaut's Support for OCI Monitoring

Collect and Analyze Application and Server Metric Data with Micronaut's Support for OCI Monitoring

The Micronaut team over in Oracle Labs have been hard at work on a number of impressive features and framework improvements and they’re moving so fast ...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!