Getting Started

Follow the steps below to get your Android application ready to receive pushes.

Firebase Cloud Messaging library is available starting with version 5.1.0 of Pushwoosh SDK only.

1. Include the following Maven repository URL in project's build.gradle:

allprojects {
    repositories {
        jcenter ()
        google()
    } 
}

2.1 Add pushwoosh and android support library dependencies into your application's build.gradle:

implementation 'com.pushwoosh:pushwoosh:5.+'
implementation 'com.android.support:support-v4:+'

Replace "+" with the current version of Pushwoosh and Android Support libraries.

2.2 Enable Java 8 support in your app build.gradle:

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Java 1.7

If you cannot use java 8 for any reason, you need to change in the app's build.gradle implementation 'com.pushwoosh:pushwoosh:5.+' to implementation 'com.pushwoosh.java7:pushwoosh:5.+'

3. Open your project in Android Studio. Go Tools > Firebase > Cloud Messaging and click "Set up Firebase Cloud Messaging":

4. Connect your app with Firebase, grant Android Studio access to your Google account (if needed), and create a new Firebase project:

If you have an existing Firebase project, choose it from the list.

5. Add FCM to your application and accept changes:

Firebase Version

Note that Firebase and play-services versions must be the same in order to avoid compatibility issues.

6. Set up the Android platform in Pushwoosh Control Panel following the steps from the configuration guide.

7. Add the following metadata to AndroidManifest.xml:

<meta-data android:name="com.pushwoosh.appid" android:value="XXXXX-XXXXX" />
<meta-data android:name="com.pushwoosh.senderid" android:value="@string/fcm_sender_id" /> 

Where:

  • com.pushwoosh.appid is your Pushwoosh Application Code
  • com.pushwoosh.senderid is the Sender ID you received from Firebase Console

Please note that you need to add fcm_sender_id to res/values/strings.xml of your Android project:

<resources>
    <string name="fcm_sender_id">123456789012</string>
</resources>

8 . Register for push notifications:

Pushwoosh.getInstance().registerForPushNotifications();

Getting Started

Follow the steps below to get your Android application ready to receive pushes.