AN_image1

AirNotifier: A How-To Guide for Beginners

Are you looking for an easy solution for handling push notifications? If the answer is Yes, then AirNotifier would be a great and user-friendly choice.

In this guide, we’ll be looking at:

  • AirNotifier: an overview
  • Getting Started with AirNotifier
  • Workflow of AirNotifier

Whether you’re new to AirNotifier, or just wanted to get an overview of how it works, this AirNotifier for beginners guide will show you what this push notification server can do and how you can get started on integrating AirNotifier into your projects. 

AirNotifier: An Overview

To start with, AirNotifier is a push notification server used for sending real-time notifications to mobile and desktop applications. A few useful features of AirNotifier include a web interface, an option to broadcast messages to all registered devices, an activity log, and a REST API. If these features sound interesting to you, then please read on for more details.

Features

Cross Platform

AirNotifier supports a range of platforms, including iOS, Android, Chrome browsers, and Windows 10 desktop applications. 

Unlimited Devices

An unlimited number of devices can be registered to AirNotifier. AirNotifier would be a good option if you don’t want to be charged when you exceed a specific number of registered devices. Whether you want to implement push notifications on a project with a small or large user base, AirNotifier will be able to handle the number of users and devices you have.

Open Source

As AirNotifier is open source, not only would this mean that the push notification server doesn’t have any additional fees, but that there is also more control over how AirNotifier can work for you. AirNotifier can be installed on your own server so you would be able to have control over the data that comes through. 

This can be a disadvantage to some people who want a push notification server that is ready right out of the box, although usually these would be paid services, like Pusher and OneSignal. AirNotifier provides a simple way of sending push notifications at no extra cost.

Web Admin UI

AirNotifier comes with a web interface that lets you configure several of its settings, view the access keys and device tokens stored, as well as an activity log that logs events such as when a new device token has been added and registered, or when a message has been sent to a registered device. 

You can also add users to your AirNotifier server, so multiple people can create and manage push notifications for different applications.

AirNotifier also has a broadcast feature where messages can be sent to all registered devices – this can be particularly useful when you want to send any urgent notifications.

The interface also features tabs for tokens and logs. The list of tokens will let you view the registered devices, whereas the logs will show when a token is registered, or deleted, or when a notification has been sent to a registered token.

Access Keys

Access keys in AirNotifier allow your sites to access AirNotifier. Multiple access keys can be created for an application, and configured with different permissions. These permissions include adding or removing device tokens, and sending notifications and broadcasts to the registered devices.

Getting started with AirNotifier

Once you’ve followed the installation steps outlined on Airnotifier’s GitHub, setting up push notifications will be a pretty straightforward experience. AirNotifier’s simple user interface makes it effortless to navigate through, so the next few steps should be easy enough to digest. 

First, we want to create a new application in AirNotifier. The sidebar on the left of the web interface will have a + Create button – clicking this will allow you to create a new app by entering the app’s short name and optionally, a description of the app. Don’t forget to save!

Once the application is created, several options will be displayed on the interface for configuration. Feel free to explore the different features and get familiar with the application interface. 

At the top, there are a few tabs for SettingsAccess keysTokens, etc.

The next step would be to create an access key so your mobile application and site can access AirNotifier. Click on the Create access key button, this will be where you set the details of the key (like a description of what the key does) and the different permissions (like whether or not you want to enable send notifications and the broadcast feature).

The access key will be generated – this key is what you’ll use when you want to send a request to AirNotifier (for example, when registering a device token, or sending a notification to a registered device).

You can make as many access keys as you like! This is a useful feature as sometimes you’d want to have different permissions for different applications. For example, you’d want to provide an access key that allows only the creation and deletion of a token – this would be used in mobile applications as devices would need to register its token to AirNotifier. On the other hand, an access key that only allows for sending notifications or broadcasts can be set in a site or backend.

Now that we’ve set up the AirNotifier application and access key(s), we can move on to setting up AirNotifier so that it can communicate with push notification services like Apple Push Notifications Service (APNs) and Firebase Cloud Messaging (FCM). This is important to set up as AirNotifier cannot directly push notifications to iOS and Android devices.

Dependencies

As outlined above, AirNotifier cannot directly send push notifications to iOS and Android devices. Instead, it needs to communicate with APNs and FCM so that the platforms’ devices can receive notifications. 

Under the Settings tab of your AirNotifier application, there should be several configuration settings for Apple’s APNs, Google’s FCM and Windows’ WNS.

To configure APNs for iOS, the Development Push Notification certificate and private key should be uploaded to AirNotifier.

The process for setting up Google’s FCM is pretty straightforward as well. For FCM, the Project ID and JSON key should be available in the Firebase app project settings (accessed through the Firebase console). This should be pasted to AirNotifier’s FCM fields (shown in the image below).

The installation guides on AirNotifier’s GitHub go into more detail on how to add the APNs/FCM settings. For iOS applications, Apple has some documentation on configuring remote notification support, whereas for Android applications, Firebase has a few guides on how to setup Cloud Messaging. These details relate more to the development of the mobile app rather than the AirNotifier setup, and assuming you’re already developing a mobile application with push notification functionality, APNs/FCM should already be included in the codebase.

Sending notifications

AirNotifier acts as a gateway between your site and APNs/FCM – communication is done through REST APIs. When you’re ready to send notifications to your devices and mobile applications, you would just need to implement a way to send POST requests to AirNotifier, along with the message we want to include in the notification. 

AirNotifier’s GitHub on its API outlines several different requests (for example, sending notifications, adding a device token, and deleting an existing device token) that can be implemented in the mobile application’s and site’s code. 

Custom options for sending notifications (like scheduling) would need to be implemented in the codebase as well – users should remember that AirNotifier can only perform simple actions and more complex functionality should be added on top of AirNotifier’s services. 

Workflow of AirNotifier

  1. Configure the APNs/FCM settings in the AirNotifier web interface. If the settings are properly configured, AirNotifier should now be able to communicate with APNs/FCM.

2. When the app is first launched, the app registers itself to APNs or FCM. APNs/FCM generates a device token and returns this to the app, where it is stored for later use. At this point, the app has the device token, and APNs/FCM can communicate with the app.

 So AirNotifier is able to communicate with APNs/FCM, and APNs/FCM is able to communicate with the app. If AirNotifier wants to send a push notification to the app, it would not be possible as of now due to AirNotifier not knowing who to send the message to (it needs a device token for this). The next few steps outline this process.

3. The app should have an access key for AirNotifier – either this is hardcoded in the app, or the app can get the key from the site database/server (the latter option would be more efficient in case the access key changes). At this point, the app has the device token and access key stored.

4. With the access key, the app can now send and register its device token to AirNotifier (this is sent through a POST request from the app). With the token now registered, AirNotifier should now know where to send the message.

5. When a site needs to send push notifications to a mobile application, the site would have to communicate with AirNotifier (by sending a POST request), and in turn AirNotifier sends the message to APNs/FCM for it to be processed and sent out to the mobile applications.

Conclusion

In conclusion, AirNotifier allows you to send push notifications to mobile devices with very minimal setup. 

Of course, there is the option of just having the site communicate with APNs and FCM directly instead of having to go through AirNotifier, but this would force you to do more work in order to integrate, update, and handle push notifications directly from the site. With AirNotifier, the site simply needs to connect with the push notification server, and AirNotifier handles the rest. 

AirNotifier is definitely an option to consider if you want to implement push notifications that are simple and straightforward.

anintro1

How to install AirNotifier with Docker

AirNotifier

AirNotifier is a great tool for software development teams. It provides a ready-made, easy-to-integrate way to send real time notifications to a range of different platforms.

Most notably, it integrates with both of the major push notification services (APNs and FCM), meaning that you don’t need to write this code yourself. This will free up your team to work on core features, while giving you confidence that your integration code was written by push-notification experts and tested in production by hundreds of other teams.

The Missing Piece

One of the biggest attractions of AirNotifier is that it gives you all of these great features for free. While they do charge for hosting, they also give you the option to self-host. If, like me, you prefer to host on your own infrastructure, AirNotifier is completely free.

That said, the main complaint that I hear about AirNotifier is its lack of documentation. This was the main reason behind our recent article, “AirNotifier: A How-To Guide for Beginners”. If you are interested in finding out more about AirNotifier’s features and how to get started, I strongly encourage you to read that article.

Without good documentation, setting up AirNotifier on your own infrastructure can take a bit of research. So, as a follow-on to our How-To Guide, I decided to write a quick-and-easy deployment guide.

Let’s Dive In

As is true for most cloud software, the easiest way to deploy AirNotifier is with Docker. At Tyne Solutions, we love Docker. Deploying AirNotifier with Docker can reduce deployment time to a matter of minutes. It becomes even easier if someone is nice enough to supply you with a ready-made Docker Compose file. So, that is exactly what we are going to do.

Step 1: Install Docker.

Installing Docker is a very straight-forward process, but the steps differ depending on your operating system. So, instead of giving you step-by-step instructions for our preferred OS, I encourage you to check out the instructions on Docker Docs (https://docs.docker.com/get-docker/). They have very detailed guides for a wide range of operating systems.

Step 2: Install Docker Compose.

Docker Compose is a separate tool that you can install on top of Docker. It enables you to manage deployments through the use of YAML files, giving you repeatable, self-documented deployments.

The installation steps for Docker Compose also differ depending on your operating system. Thankfully, Docker Docs has us covered here too. You can find installation instructions for a range of operating systems here, https://docs.docker.com/compose/install/.

Step 3: Install AirNotifier

We tried to find an existing AirNotifier image of Docker Hub, but the only images we could find were either out-dated, undocumented, or used a modified version of AirNotifier. So, we decided to create our own image and make it available to the public. Our image uses AirNotifier v2, with no modifications. You can find it here, https://hub.docker.com/r/tynesolutions/airnotifier.

Using Docker Compose, deploying this image is almost effortless. Add a new file to your server and call it docker-compose.yml. Then, add the following contents and save the file:

version: “3”

services:

  mongodb:

    container_name: mongodb

    image: mongo:latest

    ports:

      – 27017:27017

    environment:

      – MONGO_DATA_DIR=/data/db

      – MONGO_LOG_DIR=/tmp/mongo/mongo.log

    volumes:

      – ./mongo/data:/data/db

      – ./mongo/log:/tmp/mongo

    command: mongod –logpath=/dev/null # –quiet

  airnotifier:

    container_name: airnotifier

    image: tynesolutions/airnotifier:2

    links:

      – mongodb

    depends_on:

      – mongodb

    volumes:

      – ./certs:/var/airnotifier/pemdir

      – ./logs:/var/log/airnotifier

    ports:

      – 8801:8801

    environment:

      – MONGO_SERVER=mongodb

      – MONGO_PORT=27017

Once saved, open your terminal, navigate to the directory where you saved the file, and run “docker-compose up -d”.

Step 4: Start using AirNotifier

That’s all there is to it.

You now have AirNotifier running at http://your_server_ip_address:8801.