preHandleNotificationsWithUrl

Controls whether Pushwoosh should automatically handle notifications containing URLs or deep links.

By default, Pushwoosh automatically processes notifications that contain a URL or deep link in the notification payload. If an activity can handle the URL/deep link, it will be started automatically, and startActivityForPushMessage will not be called. The link is opened with an ACTION_VIEW intent carrying FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP, so a running singleTop activity receives it in onNewIntent() and activities above it in the task are closed. A running standard activity is finished and recreated with the link in onCreate(); singleTask and singleInstance activities receive it in onNewIntent(). The flags apply to whichever activity resolves the link, including one in another app.

Override this method to return false if you want to handle all URLs and deep links manually in startActivityForPushMessage.

Default Behavior (returns true): Pushwoosh attempts to open URLs/deep links using Android's Intent system. If successful, startActivityForPushMessage is skipped.

Custom Behavior (returns false): All notifications are routed to startActivityForPushMessage, giving you full control over URL/deep link handling. Example 1: Disable automatic URL handling



protected boolean preHandleNotificationsWithUrl() {
    // Disable automatic URL handling
    return false;
}


protected void startActivityForPushMessage(PushMessage message) {
    // Now YOU control all URL/deep link handling
    String url = PushBundleDataProvider.getLink(message.toBundle());

    if (url != null) {
        if (url.startsWith("myapp://")) {
            // Handle custom deep link
            handleDeepLink(url);
        } else if (url.startsWith("http")) {
            // Handle web URL with custom browser
            openInCustomBrowser(url);
        }
    } else {
        // No URL - use default launch
        super.startActivityForPushMessage(message);
    }
}

Example 2: Conditional URL handling



protected boolean preHandleNotificationsWithUrl() {
    // Let Pushwoosh handle external URLs only
    // Handle custom deep links manually
    SharedPreferences prefs = getApplicationContext()
        .getSharedPreferences("settings", Context.MODE_PRIVATE);
    return prefs.getBoolean("auto_open_links", true);
}

Return

true to enable automatic URL/deep link handling (default), false to handle all URLs manually in startActivityForPushMessage

See also