Push with OneSignal

AndroidNative plugin supports OneSignal Push Notifications.

First of all, you need to Download and Import the OneSignal Unity SDK.

When you are importing the SDK, make sure you will not import files that may cause conflicts with the libraries you already have in your project, as showed on the screenshot below:

Start using the OneSignal Push Notifications by enabling the One Signal support inside plugin settings and set One Signal App ID (how to get this values is described below):


Ones you've enabled the OneSignal API, you can choose it as the push notification service as showed on the screenshot below:


Now you need to create your OneSignal App and Setup  your Account.

So, if you have no OneSignal applications added to your OneSignal account, you should create one.

Click Add a new app in your Dashboard

To configure your OneSignal app, you have to generate Generating a GCM Push Notification Key.

To do this, you have to follow a set of instructions from the OneSignal Generating a GCM Push Notification Key guide.

Your OneSignal App ID can be found in your Application Settings board as shown below

So, just copy and paste it into AndroidNative Plugin Settings Inspector window.


You have to call GoogleCloudMessageService.instance.Init () method from your C# code at application start to init OneSignal functionality and subscribe for OneSignal Push Notifications.

GoogleCloudMessageService.instance.Init ();


OneSignal Push Notification has callback action. So, you can subscribe to

Action<string, Dictionary<string, object>, bool> ActionGameThriveNotificationReceived

action of GoogleCloudMessageService.

ActionGameThriveNotificationReceived += HandleNotification;

 // Gets called when the player opens the notification.
 private void HandleNotification(string message, Dictionary<string, object> additionalData, bool isActive) {
    // Your app logic


  • String message - The message text the user seen in the notification.
  • Dictionary<string, object> additionalData - Key-value pairs that were set on the notification.
  • boolean isActive - True if your app was currently being used when a notification came in.

C# Example:

private void HandleNotification(string message, Dictionary<string, object> additionalData, bool isActive) {
    // When isActive is true this means the player is currently in your game.
    // Use isActive and your own game logic so you don't interupt the player with a popup or menu when they are in the middle of playing your game.
    if (additionalData != null) {
      if (additionalData.ContainsKey("discount")) {
        extraMessage = "DISCOUNT!";
        // Take player to your store.
      else if (additionalData.ContainsKey("bonusCredits")) {
        extraMessage = "BONUS CREDITS!";
        // Take player to your store.


When you have finished with all settings, and all libs are downloaded and imported all necessary components, it's time to test OneSignal Push Notifications.

To start sending OneSignal Notifications from OneSignal service, you have to select your OneSignal app and navigate to New push notification menu page.

To send new Push Notification, enter Notification Title and Content. Then press Preview and Send button (in the next page).

All additional information according to OneSignal can be found in OneSignal Docs

Manifest Requirements

Here are excerpts from a sample manifest that contains needed permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="COM.YOUR.PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="COM.YOUR.PACKAGE_NAME.permission.C2D_MESSAGE" />

Plugin will add necessary receiver automatically.

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="com.onesignal.NotificationOpenedActivity"/>
 android:permission="com.google.android.c2dm.permission.SEND" >
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="COM.YOUR.PACKAGE_NAME" />
<service android:name="com.onesignal.GcmIntentService" />


An example scene can be found at: