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

Android SDK Setup

OneSignal Android SDK Setup Guide. Also for Amazon apps using Android Studio.

For Developers

Android Studio is the most common way to build Android projects. The following instructions are also applicable if you're using Android Studio to build your Amazon app (see more).
If you're still using Eclipse instead of Android studio, follow the guide here instead.

Before proceeding, follow the steps to Generating a Google Server API Key.

1. Gradle Setup

1.1 Open your build.gradle (Module: app) file and add the following to your dependencies.

dependencies {
    // OneSignal SDK
    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'
}

1.2 In the same build.gradle file, add the following in your android > defaultConfig section.

  • Update PUT YOUR ONESIGNAL APP ID HERE with your OneSignal app id
android {
   defaultConfig {
      manifestPlaceholders = [onesignal_app_id: "PUT YOUR ONESIGNAL APP ID HERE",
                              // Project number pulled from dashboard, local value is ignored.
                              onesignal_google_project_number: "REMOTE"]
    }
 }


2. Add Required Code

2.1 Add the following to the onCreate method in your Application class.

import com.onesignal.OneSignal;

public class YourAppClass extends Application {
   @Override
   public void onCreate() {
      super.onCreate();
      OneSignal.startInit(this)
        .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
        .unsubscribeWhenNotificationsAreDisabled(true)
        .init();
     
      // Call syncHashedEmail anywhere in your app if you have the user's email.
      // This improves the effectiveness of OneSignal's "best-time" notification scheduling feature.
      // OneSignal.syncHashedEmail(userEmail);
   }
}

Don't have a class that extends Application in your project?
Follow this tutorial to create one.

3. Create a default notification icon

3.1 Starting with Android Lollipop 5.0 a small notification icon is required for the icon to be visible in the status bar. Follow the Customize Notification Icons instructions to create a small notification icon.

4. Add Optional Notification Handlers

NotificationOpenedHandler - This will be called when a notification is tapped on.
See our setNotificationOpenedHandler documentation to add one.

NotificationReceivedHandler - This will be called when a notification is received.
See our setNotificationReceivedHandler documentation to add one.

NotificationExtenderService - This service can be setup to receive notifications no matter if your app is running or not. It can be used override how notifications are shown in the notification shade or to process data silently without showing a notification. See the Background Data and Notification Overriding section to set this up.

Next Steps

Android - Setup is done! All AndroidManifest.xml entries are added by our SDK for you. Make sure you are testing push notifications on a device or emulator that has Google Play services installed and updated on it.

Troubleshooting

If run into any issues please see our Android troubleshooting guide, or our general Troubleshooting section.

Additional Documentation

Android SDK Setup

OneSignal Android SDK Setup Guide. Also for Amazon apps using Android Studio.

For Developers