OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Support

Corona SDK Setup

OneSignal Corona SDK Setup Guide. Works with iOS and Android (and derivatives like Amazon).

For Developers

If you are running an Enterprise Corona app, see instructions below

Generate Credentials

Before setting up the Corona SDK, you must generate the appropriate credentials for the platform(s) you are releasing on:

iOS - Generate an iOS Push Certificate

Android - Generate a Google Server API Key

Amazon - Generate an Amazon API Key

1. Add OneSignal to your Account

1.1 Login into your account on Corona's site and bring up the OneSignal plugin on the Corona plugin directory.

1.2 Click the "FREE" button.

1.3 Click "Finish Checkout".


2. Add OneSignal to Your Project

2.1 Update the build.settings file in the Corona project folder to contain the following inside of settings = {.

plugins =
{
    ["plugin.OneSignal"] =
    {
        publisherId = "com.onesignal",
    },
    -- Uncomment if you are using Corona Build SDK 2016.3004 or older.
  --[[
    ["plugin.google.play.services"] =
    {
        publisherId = "com.coronalabs",
        supportedPlatforms = { android=true },
    },
  --]]
}

2.2 iOS - Add the following line inside of 'plist = {' in build.settings.

UIBackgroundModes = {"remote-notification"},

3. Add Required Code

3.1 At the top of main.lua, place the following code.

-- This function gets called when the user opens a notification or one is received when the app is open and active.
-- Change the code below to fit your app's needs.
function DidReceiveRemoteNotification(message, additionalData, isActive)
    if (additionalData) then
        if (additionalData.discount) then
            native.showAlert( "Discount!", message, { "OK" } )
            -- Take user to your app store
        elseif (additionalData.actionSelected) then -- Interactive notification button pressed
            native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"} )
        end
    else
        native.showAlert("OneSignal Message", message, { "OK" } )
    end
end

local OneSignal = require("plugin.OneSignal")
-- Uncomment SetLogLevel to debug issues.
-- OneSignal.SetLogLevel(4, 4)
OneSignal.Init("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "############", DidReceiveRemoteNotification)

3.2 Replace XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX with your Application Key, available in Keys & IDs.

3.3 Android - Replace ############ with your Google Project number.

3.4 Amazon - Put your app_key.txt (from Generate an Amazon API Key instructions above) into the root of your Corona project folder. When you build your app change the Target App Store setting to Amazon.


Troubleshooting

If get an error saying "Plugin_OneSignal not found" make sure the plugin shows active on your account on the Corona's plugin directory page. Also make sure the same account you used on their site is the same account you signed into in the Corona Simulator. If that is correct you may need to wait 30 minutes up to 1 hour for OneSignal to become active on your account. Feel free to contact us or Corona if this error persists.


Setup SDK (Corona Enterprise)

Generate Credentials

Before setting up the Corona SDK, you must generate the appropriate credentials for the platform(s) you are releasing on:

iOS - Generate an iOS Push Certificate

Android - Generate a Google Server API Key

Amazon - Generate an Amazon API Key

1. Add Required Code

1.1 At the top of main.lua, place the following code.

-- This function gets called when the user opens a notification or one is received when the app is open and active.
-- Change the code below to fit your app's needs.
function DidReceiveRemoteNotification(message, additionalData, isActive)
    if (additionalData) then
        if (additionalData.discount) then
            native.showAlert( "Discount!", message, { "OK" } )
            -- Take user to your app store
        elseif (additionalData.actionSelected) then -- Interactive notification button pressed
            native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"} )
        end
    else
        native.showAlert("OneSignal Message", message, { "OK" } )
    end
end

local OneSignal = require("plugin.OneSignal")
OneSignal.Init("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "############", DidReceiveRemoteNotification)

1.2 Replace XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX with your Application Key in Keys & IDs.

1.3 Replace ############ with your Google Project number if your app is for Android.

2. Add Plugin to iOS

iOS

2.1 Extract onesignal/XXXX.XXXX/iphone/ from the CoronaEnterprisePlugins.XXXX.XXXX.tgz. (found on the Corona Daily Builds page under Corona Enterprise)

2.2 Add libplugin_OneSignal.a to your Xcode project.

2.3 Add Required Capabilities
2.3A Select the root project and Under Capabilities Enable "Push Notifications".
2.3B Next Enable "Background Modes" and check "Remote notifications".

2.4 Open your -Info.p file add the key CoronaDelegates as an Array type. Add an entry as OneSignalCoronaDelegate.

3. Add Plugin to Android

Android & Amazon

3.1 Extract onesignal/XXXX.XXXX/android/ from the CoronaEnterprisePlugins.XXXX.XXXX.tgz. (found on the Corona Daily Builds page under Corona Enterprise)

3.2 Create a folder named armeabi-v7a under android/libs in your project and place the libplugin.OneSignal.so there.

3.3 Copy OneSignal.jar, OneSignalSDK.jar, and android-support-v4.jar to your android/libs folder.

3.4 Add the following permissions to your AndroidManifest.xml file.

<permission android:name="COM.YOUR.PACKAGE_NAME.permission.C2D_MESSAGE"
            android:protectionLevel="signature"/>
<uses-permission android:name="COM.YOUR.PACKAGE_NAME.permission.C2D_MESSAGE"/>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>

<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

3.5 In the application tag add the following.

<application ...>
    <meta-data android:name="com.google.android.gms.version"
       android:value="@integer/google_play_services_version" />

  	<receiver android:name="com.onesignal.NotificationOpenedReceiver" />
		
    <receiver
        android:name="com.onesignal.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="COM.YOUR.PACKAGE_NAME" />
        </intent-filter>
    </receiver>
    <service android:name="com.onesignal.GcmIntentService" />
    <service android:name="com.onesignal.SyncService" android:stopWithTask="false" />
    <activity android:name="com.onesignal.PermissionsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>

3.6 (Optional) If you need receive other GCM message through Corona (like Helpshift) then add the following to your AndroidManifest.xml.

<receiver
  android:name="com.onesignal.CoronaGCMFilterProxyReceiver"
  android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="COM.YOUR.PACKAGE_NAME" />
    </intent-filter>
</receiver>

3.7 Replace 'COM.YOUR.PACKAGE_NAME' with your full package name from the last 2 steps.

3.8 Open your android/project.properties and the following.

android.library.reference.2=relative_path/google-play-services_lib

The path you add MUST be relative and not absolute and should look something like this ../../../android-sdks/extras/google/google_play_services/libproject/google-play-services_lib.

3.9 Build you app. If you get an error about build.xml is missing then cd to the google-play-services_lib folder in the andorid sdk and run

android update lib-project --path . --target android-10

Proguard

If you have proguard enabled on your project you must add the following lines to your proguard config file. (Default name is proguard-project.txt).

-dontwarn com.onesignal.**
-dontwarn com.gamethrive.**

4. Add Plugin to Amazon

Amazon

4.1 Follow all the steps from Add Plugin to Android

4.2 Add the following permission to your AndroidManifest.xml

<uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
<permission android:name="COM.YOUR.PACKAGE_NAME.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="COM.YOUR.PACKAGE_NAME.permission.RECEIVE_ADM_MESSAGE" />

4.3 In the application tag add the following.

<application ...>
  <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false" xmlns:amazon="http://schemas.amazon.com/apk/res/android" />

  <service android:name="com.onesignal.ADMMessageHandler" android:exported="false" />
  <receiver
            android:name="com.onesignal.ADMMessageHandler$Receiver"
            android:permission="com.amazon.device.messaging.permission.SEND" >

    <intent-filter>
      <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
      <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
      <category android:name="COM.YOUR.PACKAGE_NAME" />
    </intent-filter>

  </receiver>
</application>

4.4 Replace COM.YOUR.PACKAGE_NAME with your full package name from the last 2 steps.

4.5. Put your app_key.txt into the root of your Corona project folder. To get this file follow our Generate an Amazon API Key instructions.

Done! You should be all set to go with your Corona app.

Corona SDK Setup

OneSignal Corona SDK Setup Guide. Works with iOS and Android (and derivatives like Amazon).

For Developers