Push notifications are used where it is important to be informed about events automatically and as promptly as possible. For example, in the event of a burglary alarm, clients are notified immediately of this event (see example application ESP32MQTTAlarmSystem).
The RadioShuttle MQTT push server does just that. Monitored MQTT topics are immediately forwarded to a mobile device, where the message is then displayed together with an audio signal as a push notification.
Different components play together in push notifications:
Push services by Apple and Google
For mobile devices, manufacturers offer so-called push services. This means that push notifications are automatically displayed directly on the mobile device. If there is no reception, the message is sent as soon as the mobile device is available again. The push services are the link between the RadioShuttle app and the RadioShuttle MQTT push server.
The app manages push notification settings. All push notifications can also be viewed there. After one-time setup, push notifications are automatically received even if the app is not running. The app is the link between the RadioShuttle MQTT push server and the push services of Apple, or Google respectively.
The app offers the following functions:
- Automatic display of push notifications with sound on the mobile device (even if the app is not active or the screen is locked)
- Notification within seconds
- User account management (MQTT server address with user name and password)
- Management of MQTT topics, which should trigger a push notification (alarm). Push notification can be activated/deactivated with sound for individual topics
- Multiple users can use the same account. Example: mother, father, child. Everyone automatically uses the same settings. All are notified at the same time
- One app can use multiple MQTT accounts. Example: Residential house in Reading, holiday home in Cornwall, business office in London
- Reports of the last 30 days can be viewed
The RadioShuttle app is available for iOS and Android and can be downloaded for free from the Apple App Store or Google Play Store. The source code of the push server and the apps (Android and iOS) is available to our customers and can be adapted for projects/solutions and published as a separate app.
MQTT Server (Broker)
The MQTT server manages messages for a user account with the registered topics. It is the link between the remote nodes or sensors and the push server.
MQTT Push ServeR
The RadioShuttle MQTT push server is the link between the MQTT server, the mobile app, and the push notifications sent via Google or Apple. The push server itself does not have its own user accounts, but logs on to the MQTT server on behalf of the user and monitors messages from topics that are to be converted into push notifications.
The use of the public push server (push.radioshuttle.de) is free of charge for RadioShuttle licensees, i.e. customers of a RadioShuttle board (currently ECO Power or LongRa), up to three mobile devices and three different accounts.
Unlimited commercial use of the RadioShuttle MQTT push server software for operation on your own servers is available for an annual software rental with support included. The Java written source code of the push server is now available (subject to non-disclosure agreement). This requires Apple or Google push certificates.
The MQTT push server itself is trimmed for security and availability. Cached configurations (certificates and settings) are AES-encrypted so that attackers with root access do not receive usable data. Misuse of push notifications is throttled and collected to prevent overload and prevent providers such as Google or Apple from blocking access. When the push or MQTT server is restarted, the connection is automatically re-established.
Note: This solution is currently in the test phase. However, the “MQTT Push Client” app for Android is already available in the Google Store. An iOS version of the app will follow soon.
Q & A
What if a mobile device hasn’t been active for a longer period?
With Google Push Notifications, a maximum of 99 messages per mobile device are stored and delivered as soon as the mobile device is online again. When reaching more than 100 pending messages that could not be delivered, Google deletes all push notifications for this mobile device. Only after it is online again will Google activate the receipt of new messages for the mobile device concerned. Mobile devices that are regularly online (fewer than 100 messages pending) work properly.
Nevertheless, the next time the app is opened, the last 100 messages are loaded (synchronized) directly from the server, unless they have already been delivered via cloud messaging.
How many push notifications can be sent?
Basically, manufacturers Google and Apple don’t like to see mobile devices “spammed” with push notifications. Therefore it is recommended to send only a few important messages via MQTT. The RadioShuttle MQTT push server delays messages for individual mobile devices if more than one message is sent within 20 seconds. This delay can range from 20 seconds to two hours, depending on how many messages are spammed. After the delay has elapsed, the messages are delivered collectively.
- Send alarm messages once, send them again after one minute if necessary. If further messages are desired so that the user looks at their mobile device, it is recommended to send further messages only at intervals of 30 minutes
- It is advided to send status messages (temperature, statistics, etc.) only every 30 minutes, or only if changes are made. Push notifications can be set to silent in the app per topic (e.g. “status messages”) so that the mobile device does not answer but messages are still available in the app
- Please ensure that no more messages are sent per mobile device than necessary, e.g. do not send identical messages twice
- It is recommended not to send more than 50 messages per day to a mobile device. Technically speaking, more is also possible, but this is not recommended in the long run
What if Google’s/Apple’s push services fail?
If the Apple/Google push services fail, the RadioShuttle MQTT push server tries to deliver the notifications as soon as the service is back online. So nothing is lost.
You can open the app at any time. In this case, the app connects to the MQTT push server, loads the last 100 messages into the app and displays them immediately.
Can the RadioShuttle MQTT push server be operated on its own server?
Installing and operating the MQTT push server on its own server is basically possible. The following prerequisites must be fulfilled:
- Computer running Java 1.7 (update 80) or newer
- Own Apple and Google developer account
- Domain name of own push server must be communicated to us
- RadioShuttle licensees, i.e. customers of a RadioShuttle board, have access to the software
- The Android or iOS apps must be published under their own name with their own app ID
- Have an SSL server certificate created (by RadioShuttle or by an certification authority)
Does this solution work without public Internet?
The MQTT server (“Broker”) and the RadioShuttle MQTT push server can also be operated in a private network. The app can also be used in this private network via WiFi or VPN and view the last 100 messages, but without push notification.
For push notifications, the RadioShuttle MQTT push server requires Internet access to send them. Internet access is only outgoing and can also be via a web proxy.
Does the RadioShuttle MQTT push server require its own access data?
No, the RadioShuttle MQTT push perver connects to the MQTT server (“Broker”) and forwards the entered access data to the MQTT server. The latter then decides whether access is permitted.
How can push notifocations be disabled?
An easy way is to remove the app from your mobile device. You can also simply delete the account for the MQTT server in the app. In addition, individual topics can be deleted from the app.
Which Android and iOS versions are required?
- Android 4.1 or newer
- iOS 11 or newer