Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public class IterableConfig {
*/
final IterableDecryptionFailureHandler decryptionFailureHandler;

/**
* Handler for push notification click events.
* Called when a user taps on a push notification, providing the notification payload data.
*/
final IterableNotificationClickHandler notificationClickHandler;

/**
* Mobile framework information for the app
*/
Expand Down Expand Up @@ -183,6 +189,7 @@ private IterableConfig(Builder builder) {
decryptionFailureHandler = builder.decryptionFailureHandler;
mobileFrameworkInfo = builder.mobileFrameworkInfo;
webViewBaseUrl = builder.webViewBaseUrl;
notificationClickHandler = builder.notificationClickHandler;
}

public static class Builder {
Expand Down Expand Up @@ -211,6 +218,7 @@ public static class Builder {
private IterableIdentityResolution identityResolution = new IterableIdentityResolution();
private IterableUnknownUserHandler iterableUnknownUserHandler;
private String webViewBaseUrl;
private IterableNotificationClickHandler notificationClickHandler;

public Builder() {}

Expand Down Expand Up @@ -465,6 +473,18 @@ public Builder setWebViewBaseUrl(@Nullable String webViewBaseUrl) {
return this;
}

/**
* Set a handler for push notification click events.
* The handler will be called when a user taps on a push notification,
* providing the notification payload data.
* @param notificationClickHandler Notification click handler provided by the app
*/
@NonNull
public Builder setNotificationClickHandler(@NonNull IterableNotificationClickHandler notificationClickHandler) {
this.notificationClickHandler = notificationClickHandler;
return this;
}

@NonNull
public IterableConfig build() {
return new IterableConfig(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.iterable.iterableapi;

import android.os.Bundle;
import androidx.annotation.NonNull;

/**
* Handler interface for push notification click events.
* Register this handler through {@link IterableConfig.Builder#setNotificationClickHandler}
* to be notified when a user taps on a push notification.
*/
public interface IterableNotificationClickHandler {

/**
* Called when a push notification is clicked by the user.
*
* @param notificationData The parsed notification metadata (campaign ID, template ID, message ID, etc.)
* @param extras The full Intent extras Bundle including the raw Iterable JSON payload
* under the key {@link IterableConstants#ITERABLE_DATA_KEY}
*/
void onNotificationClicked(@NonNull IterableNotificationData notificationData, @NonNull Bundle extras);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Created by davidtruong on 5/23/16.
*/
class IterableNotificationData {
public class IterableNotificationData {
static final String TAG = "IterableNoticationData";

private int campaignId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ static boolean executeAction(Context context, PendingAction action) {
// Automatic tracking
IterableApi.sharedInstance.setPayloadData(action.intent);
IterableApi.sharedInstance.setNotificationData(action.notificationData);

// Invoke notification click handler if registered
if (IterableApi.sharedInstance.config.notificationClickHandler != null && action.intent.getExtras() != null) {
IterableApi.sharedInstance.config.notificationClickHandler.onNotificationClicked(
action.notificationData, action.intent.getExtras());
}

IterableApi.sharedInstance.trackPushOpen(action.notificationData.getCampaignId(), action.notificationData.getTemplateId(),
action.notificationData.getMessageId(), action.dataFields);

Expand Down
Loading