OneSignal Plugin

Integrate with OneSignal Push to send cross-platform push notifications.

Increase Engagement

Push notifications are a direct channel to your app's users. Keep them happy and engaged with app updates, promotions, and more sent directly to their device.

Targeted Push Notifications

Send notifications to all users, a targeted segment or an individual user, thanks to push tags it has never been easier to send push notifications.


Push Notifications are a great way to keep users engaged and inform users about updates in your app.

In comparison to local notifications push notifications are triggered from a server-side logic. To make things easier OneSignal provides a push backend for delivering notifications from a custom web-service or with the help of their Push Notification Dashboard.

Therefore push notifications are ideally suited for applications where you want to inform your users about externally triggered status updates, like sports live ticker apps, social messaging apps or any other app which should inform your users about an update.

Note: If you only need scheduled local notifications that don't require any external logic to be triggered have a look at our Notification Plugin.

Example Usage

To see an integration example of the OneSignal plugin have a look at the V-Play Plugin Demo app.

Push notifications can either be sent to all registered devices or targeted by setting "tags".

To use push notifications in your app add the following item to your QML code:

 import QtQuick 2.1
 import VPlayPlugins 1.0

 OneSignal {
   id: onesignal

   appId: "<ONESIGNAL-APP-ID>"

Note: You can retrieve the <ONESIGNAL-APP-ID> from your OneSgignal Dashboard, for more information have a look at the section OneSignal Account.

To set specific tag called key with value value for a user, you can call the OneSignal::sendTag() method:

 onesignal.sendTag("key", "value")

You can disable all push notifications independently from tags by setting the enabled property to false:

 OneSignal {
   enabled: false // Disables all push notifications for the device

To handle an incoming push notification implement the OneSignal::notificationReceived signal handler:

 OneSignal {

   onNotificationReceived: {
     console.debug("Received notification with message:", message)


The additionalData parameter is a map containing a JSON object content with all parameters of the push notification payload sent over OneSignal.

The signal is emitted in following cases:

  • If the app is currently in the foreground the signal is emitted immediately, there isn't however a sound played and no banner is displayed.

    You can disable that behavior on Android only when setting the OneSignal::notificationWhenActive property to true. On iOS, the notification is always delivered when active.

  • If the app is in the background the system plays a short notification sound and displays a banner with your provided Parse alert payload. If the user then taps the notification the app goes to the foreground and the signal is emitted.

Sending Push Notifications

The OneSignal Plugin supports receiving simple text-based push messages or more advanced JSON payload messages, sent over the OneSignal Push API.

To test push notifications on your device you can use any library or tool which supports HTTP POST requests. Here is an example how to send a push notification with the help of curl:

 curl --include \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Basic <ONESIGNAL-REST-API-KEY>" \
      --data-binary '{
         "app_id": "<ONESIGNAL-APP-ID>",
         "contents": { "en": "Message" }
      }' \

Note: You can retrieve the <ONESIGNAL-REST-API-KEY> and <ONESIGNAL-APP-ID> from your OneSignal Dashboard, for more information have a look at the section OneSignal Account.

You can define the text which should be shown within the notification in the contents block. The text is provided within the OneSignal::notificationReceived handler as message parameter.

If you want to target your push notifications to a specific tag you can add it to the payload in an array like:

 curl --include \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Basic <ONESIGNAL-REST-API-KEY>" \
      --data-binary '{
         "app_id": "<ONESIGNAL-APP-ID>",
         "contents": { "en": "Message" },
         "tags": [{"key": "userId", "relation": "=", "value": "1"}]
      }' \

This push notification is only sent to users with a userId tag set to 1.

Beside the "=" relation it's also possible to use ">", "<", and "=". "<" means that the value of the user's tag must be less than the value supplied in the "value" field of the hash.

By default users must match all of the hashes specified in the tags array to receive the notification. You may add {"operator": "OR"} between the entries to allow any of the tag conditions. A maximum of 200 tags and operators can be used at a time.

Here are advanced examples of combining different tags:

Example 1: level='10' AND madePurchase='true':

   {"key": "level", "relation": ">", "value": "10"},
   {"key": "madePurchase", "relation": "=","value": "true"}

Example 2: level='10' OR level='20'

   {"key": "level", "relation": "=", "value": "10"},
   {"operator": "OR"},
   {"key": "level", "relation": "=", "value": "20"}

As stated it is also possible to combine different tags.

Advanced Usages

Beside sending simple text messages within the contents block you can also send a more advanced payload for the following use-cases:

Navigating to a Specific Screen From Push Notifications

It's possible to send additional key/values beside your content payload. As an example you can send a screen code which you can navigate to when a user opens your app from a push notification. For this use case append additional keys to the JSON payload. The following example defines an additional key named screen:

 curl --include \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Basic <ONESIGNAL-REST-API-KEY>" \
      --data-binary '{
         "app_id": "<ONESIGNAL-APP-ID>",
         "contents": { "en": "Message" },
         "data": { "screen": "Inbox" }
      }' \

In you QML code you can then read the key by referencing it in the data parameter:

 OneSignal {

   onNotificationReceived: {
     // Get the screen key from the data payload
     var screen = additionalData["screen"]

     // TODO: Navigate user to the appropriate screen


Note: Please keep in mind that the payload's length for push notifications is restricted by Apple's and Google's push notification payload. Therefore make sure that you keep your information reasonable small and postpone loading additional data after your user opens your app again.

Available QML Items


Item provides remote push notifications for iOS & Android over the OneSignal service


To use the Parse plugin you need to add the platform-specific native libraries to your project, described here:

iOS Integration Steps

  1. Download our PluginDemo from and unzip it.
  2. Copy OneSignal.framework from the ios sub-folder to a sub-folder called ios within your project directory.
  3. Add the following lines of code to your .pro file:
     ios {
       VPLAY_PLUGINS += onesignal

Android Integration Steps

  1. Open your build.gradle file and add the following lines to the dependencies block:
     dependencies {
       compile 'net.vplay.plugins:plugin-onesignal:2.+'
  2. Check if that your build.gradle file includes the following line within the android block (replace 'Identifier' with your project's package identifier, as given in AndroidManifest.xml):
     android {
       defaultConfig.applicationId = 'Identifier'

    Note: If you did not create your project from any of our latest wizards, make sure that your project uses the Gradle Build System like described here.

  3. By default, the app's launcher icon will be used as notification icon within the status bar. Starting with Android 5, the OS forces notification icons to be all white when your app targets Android API 21 and above.

    It is therefore recommended to provide a distinct notification icon of size 24x24px (mdpi) with the name ic_stat_onesignal_default.png within your Android app's resources.

OneSignal Account

You finally need to set up a OneSignal account at Then open your OneSignal dashboard and add a new app. There you can also find your application id and REST API keys in the app's settings.

To receive push notifications on iOS you also have to create a new developer and distribution push certificate (with a push-enabled iOS app id) at and upload them to the app's push settings.

Used OneSignal SDK Versions

iOS SDK 2.0.9
Android SDK 3.4.3

Note: Other SDK versions higher than the stated ones might also be working but are not actively tested as of now.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support