Integrate Pushwoosh Android SDK

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

Watch this video where our dedicated Customer Success team will guide you through the onboarding process at Pushwoosh, from setting up projects to sending your first communications.

Requirements

Integration

For Gradle Versions less than 6.8

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

build.gradle
allprojects {
    repositories {
        google ()
        mavenCentral()
    } 
}

Add pushwoosh library dependencies into your application's build.gradle:

build.gradle
implementation 'com.pushwoosh:pushwoosh-firebase:6.+'

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

For Gradle Versions 6.8 or Higher

Locate the Settings.gradle file in the root directory of your project.

Open the Settings.gradle file and declare the repositories like this:

// pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

Then, save the changes.

Next, open your project in Android Studio. Go Tools > Firebase > Cloud Messaging and click "Set up Firebase Cloud Messaging":

Connect your app with Firebase, grant Android Studio access to your Google account (if needed), and choose your Firebase project.

Then add FCM to your application and accept changes:

Add the following metadata to AndroidManifest.xml:

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" /> 
<meta-data android:name="com.pushwoosh.apitoken" android:value="your_api_token" />

Where:

  • com.pushwoosh.appid is your Pushwoosh Application Code located below the name of your application.

  • com.pushwoosh.senderid is the Sender ID you received from Firebase Console.

  • com.pushwoosh.apitoken requires an API Access Token, which you can generate by navigating to Settings > API Access in

    your Pushwoosh account and copying the generated token.

Please note that you must add meta-data inside the <application> tag

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

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

Finally, register for push notifications:

Pushwoosh.getInstance().registerForPushNotifications()

Testing push notifications on test devices

If you want to test push notifications on test devices without affecting the production environment, follow the steps below. If you do not need to use this functionality, skip this section.

  1. Add DeepLinkActivity to your AndroidManifest.xml:

<activity
          android:name="com.pushwoosh.DeepLinkActivity"
          android:theme="@android:style/Theme.Translucent.NoTitleBar" >
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="pushwoosh-YOUR_PUSHWOOSH_APP_ID" />
  </intent-filter>
</activity>

Don't forget to replace YOUR_PUSHWOOSH_APP_ID in the xml above with your Pushwoosh App ID. Example: <data android:scheme="pushwoosh-ABCDE-EDCBA" />

  1. Launch the application to subscribe for push notifications.

  2. Scan the QR Code in Test Devices form using any appropriate QR Code scanner app*. A toast message will appear indicating the status of the test device registration.

* – most of the QR code scanning apps handle such deep links properly, here are just a few of them:

Next steps

Share your feedback with us

Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.

Last updated