Migration to Android SDK 5.0

Most of Pushwoosh classes and methods became deprecated since 5.0 release and some of them became extinct. PushManager, BasePushMessageReceiver, BaseRegistrationReceiver, SendPushTagsCallback, PushFragment and PushEventListener classes are still available as part of com.pushwoosh:pushwoosh-deprecated library but it is recommended to migrate to new API as soon as possible.


PushManager consisted of various methods for different features. These methods are now split between different classes and libraries:
com.pushwoosh:pushwoosh: Pushwoosh, PushwooshNotificationSettings, PushwooshInApp.
com.pushwoosh:pushwoosh-badge: PushwooshBadge.
com.pushwoosh:pushwoosh-location: PushwooshLocation.
com.pushwoosh:pushwoosh-beacon: PushwooshBeacon.


BaseRegistrationReceiver was used to handle push registration and unregistration events. This receiver is now replaced by simple callback mechanism:

Pushwoosh.getInstance().registerForPushNotifications(result -> {
    if (result.isSuccess()) {
        String token = result.getData();
        // handle successful registration
    else {
        PushwooshException exception = result.getException();
        // handle registration error


BasePushMessageReceiver was used to imitate iOS notification behaviour when receiving push notification in foreground. It was achieved by cancelling incoming notification and invoking onMessageReceive callback. It was clunky and required manual registration when application becomes active and deregistration when application goes background.
This receiver was replaced by NotificationServiceExtension:

public class YourNotificationServiceExtension extends NotificationServiceExtension {
    public boolean onMessageReceived(final PushMessage message) {
        if (isAppOnForeground()) {
            Handler mainHandler = new Handler(getApplicationContext().getMainLooper());
            mainHandler.post(() -> {

            // this indicates that notification should not be displayed
            return true;

        return false;

    protected void startActivityForPushMessage(PushMessage message) {

    private void handlePush(PushMessage message) {
        // TODO: handle push message

This extension is also used to handle notification arrival and accept events thus replacing all clunky code that was used in manual Activity integration.


PushFragment was a lightweight alternative for the complex integration involving Activity lifecycle. But on the other hand it required FragmentActivity inheritance and implicitly used more complex Fragment lifecycle.
PushFragment and PushEventListener are now replaced by Pushwoosh#registerForPushNotifications(Callback) and NotificationServiceExtension.

Custom Push Broadcast Receiver (PW_NOTIFICATION_RECEIVER)

PW_NOTIFICATION_RECEIVER was used to customise behaviour when user clicks on notification. This allowed to handle notifications outside of Activity context and to open different Activities depending on notification content. This integration used internal Pushwoosh SDK API which no longer exists.
This receiver is now completely replaced by NotificationServiceExtension:

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());

Notification Factory

There also were some breaking changes involving notification factory:

1. AbsNotificationFactory was replaced by NotificationFactory
2. AbsNotificationFactory#onPushReceived(PushData) and AbsNotificationFactory#onPushHandle(Activity) methods replaced by NotificationServiceExtension class (onMessageReceived, startActivityForPushMessage).
3. DefaultNotificationFactory was replaced by PushwooshNotificationFactory.
4. PushData was replaced by PushMessage.

In-App Messages

1. InAppFacade was replaced by PushwooshInApp.
2. pushwoosh object was inroduced for JavaScript native interface with following API:
getHwid(): string - returns pushwoosh hwid for current device.
getVersion(): string - returns current pushwoosh SDK version.
postEvent(event: string, attributes?: object, successCallback?: function, errorCallback?: function) - sends postEvent request.
sendTags(tags: object) - send tags associated with current device.
getTags(successCallback: function, errorCallback?: function) - returns tags associated with current device.
closeInApp() - closes In-App html page.

Migration to Android SDK 5.0