Customizing Android SDK 5.0

In App Purchase tracking

In order to track in-app purchases you should call the sendInappPurchase method of the Pushwoosh class when a user buys a product:

public void sendInappPurchase(java.lang.String sku,
                              java.math.BigDecimal price,
                              java.lang.String currency)
  • sku – purchased product ID
  • price – price of the product
  • currency – currency of the price (ex: “USD”)


Pushwoosh.getInstance().sendInappPurchase("com.example.inapp1", new BigDecimal(1.99), "USD");

Deep linking

In your activity that will handle the deep link add <data> tag with the scheme, host and pathPrefix parameters.

        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data android:scheme="com.pushwoosh"
          android:pathPrefix="" />

Note that deep link page name (promotion in the example) goes to the host field, not pathPrefix.

In the example above the deep link will open PromoActivity. The basic implementation below displays alert with promo id value for the sake of simplicity. In your application it could definitely do something useful!

public class PromoActivity extends Activity
		protected void onCreate(Bundle savedInstanceState)

				setTitle("Deep link activity");
				Intent intent = getIntent();
	  	  String action = intent.getAction();
	    	Uri data = intent.getData();
		    if (TextUtils.equals(action, Intent.ACTION_VIEW))
		private void openUrl(Uri uri) 
				String promoId = uri.getQueryParameter("id");
				Toast.makeText(getApplicationContext(), promoId, Toast.LENGTH_LONG).show();

Geozones push notification

To use geozone pushes simply add com.pushwoosh:pushwoosh-location library and call


It is recommended to check dynamic permissions android.Manifest.permission.ACCESS_FINE_LOCATION and android.Manifest.permission.ACCESS_COARSE_LOCATION before invoking this method

Using Local Notifications with Pushwoosh

If you use Pushwoosh Local Notifications API add RECEIVE_BOOT_COMPLETED permission to your AndroidManifest.xml:

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

Using Badge Number on Android

Pushwoosh supports setting badge number on the app icon shortcut for the following Android launchers:
Sony, Samsung, LG, HTC, Xiaomi, ASUS, ADW, APEX, NOVA, HUAWEI, ZUK, OPPO.
To use this functionality simply add com.pushwoosh:pushwoosh-badge library to your application.

Opening custom activity

If you want to start particular activity in response to push notifications add the following intent-filter to that activity.

<activity android:name="YourActivity">
        <action android:name="${applicationId}.MESSAGE"/>
        <category android:name="android.intent.category.DEFAULT"/>

Controlling Log Level

In order to assist with debugging and integration, SDK will print all the requests to the console by default. When you ready for the production build, add com.pushwoosh.log_level meta-data with value "ERROR" to the AndroidManifest.xml. This way only information about errors will go to the console. Other option could be one of the following:

NONE - No logs from the SDK
ERROR - Display only errors in the console
WARN - Display also a warnings
INFO - Display informational messages
DEBUG - Even debug information is displayed now
NOISE - Everything SDK can print and more

<meta-data android:name="com.pushwoosh.log_level" android:value="ERROR" />

Using Proguard

When using Proguard add the following options:

-keep class com.pushwoosh.** { *; }
-dontwarn com.pushwoosh.**

Also see Google Play Services library requirements regarding Proguard here:

Customising Notification open behaviour

If you need to programmatically select which activity to display as a result of push notification, you can create custom NotificationServiceExtension and include fully qualified class name of your NotificationServiceExtension in metadata under com.pushwoosh.notification_service_extension value.

    android:value="com.your.package.YourNotificationServiceExtension" / >
public class YourNotificationServiceExtension extends NotificationServiceExtension {
    protected void startActivityForPushMessage(PushMessage message) {
      // super.startActivityForPushMessage() starts default launcher activity 
      // or activity marked with ${applicationId}.MESSAGE action.
      // Simply do not call it to override this behaviour.
        // super.startActivityForPushMessage(message);

        // start your activity instead:
        Intent launchIntent  = new Intent(getApplicationContext(), YourActivity.class);             
        launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        // (Optional) pass notification data to Activity
        launchIntent.putExtra(Pushwoosh.PUSH_RECEIVE_EVENT, message.toJson().toString());

Customizing push notifications

To customize the view of push notifications you need to create a custom Factory, you can create custom NotificationFactory and include fully qualified class name of your NotificationFactory in metadata under com.pushwoosh.notification_factory value.

    android:value="com.your.package.YourNotificationFactory" / >
public class YourNotificationFactory extends PushwooshNotificationFactory {
	public Notification onGenerateNotification(@NonNull PushMessage pushMessage) {
		if (customNotification) {
       // TODO: generate and return custom notification
    // return default Pushwoosh notification
		return super.onGenerateNotification(pushMessage);

Private Endpoint URL

Enterprise only.

Pushwoosh provides Private endpoints for Enterprise customers. To set up Private endpoint for Android SDK you need to add the following to your AndroidManifest.xml file

<meta-data android:name="com.pushwoosh.base_url" android:value="PUSHWOOSH_PRIVATE_ENDPOINT_URL_PROVIDED" />

Customizing Android SDK 5.0