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.
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 = message.getLink();
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