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:
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.
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.
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!
We need to set our Application and User keys into the serverless config so that we can access them from our function later on.
Before we edit the function, modify package.json to include the dependency on the pushover library.
func.js to send the notification.
Deploy the function with:
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!
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!
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.
A while back, I blogged about using Oracle Advanced Queuing (AQ) for messaging within your applications. It's a great option for durable and reliable...
I’ve written about messaging many, many times on this blog. And for good reason, too. It’s a popular subject that developers can’t seem to get enough of...
When working in the cloud, there are often times when your servers and services are not exposed to the public internet. Private virtual cloud networks ...