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
1 change: 1 addition & 0 deletions iterableapi/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:name=".IterableTrampolineActivity"
android:exported="false"
android:launchMode="singleTask"
android:taskAffinity=""
android:excludeFromRecents="true"
android:theme="@style/TrampolineActivity.Transparent"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class IterableAction {

/** Open the URL or deep link */
public static final String ACTION_TYPE_OPEN_URL = "openUrl";
public static final String ACTION_TYPE_OPEN_APP = "openApp";

private final @NonNull JSONObject config;

Expand Down Expand Up @@ -68,6 +69,8 @@ static IterableAction actionCustomAction(@NonNull String customActionName) {
* If {@link #ACTION_TYPE_OPEN_URL}, the SDK will call {@link IterableUrlHandler} and then try to
* open the URL if the delegate returned `false` or was not set.
*
* If {@link #ACTION_TYPE_OPEN_APP}, the SDK will open the app's main activity.
*
* For other types, {@link IterableCustomActionHandler} will be called.
* @return Action type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ boolean executeAction(@NonNull Context context, @Nullable IterableAction action,

if (action.isOfType(IterableAction.ACTION_TYPE_OPEN_URL)) {
return openUri(context, Uri.parse(action.getData()), actionContext);
} else if (action.isOfType(IterableAction.ACTION_TYPE_OPEN_APP)) {
return false;
} else {
return callCustomActionIfSpecified(action, actionContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IterableCustomActionHandler {
* Callback called for custom actions from push notifications
* @param action {@link IterableAction} object containing action payload
* @param actionContext The action context
* @return Boolean value. Reserved for future use.
* @return true if your app handled the action, false otherwise
*/
boolean handleIterableCustomAction(@NonNull IterableAction action, @NonNull IterableActionContext actionContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.AndroidRuntimeException;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Gravity;
Expand Down Expand Up @@ -200,9 +201,12 @@
applyWindowGravity(getDialog().getWindow(), "onCreateView");
}

webView = new IterableWebView(getContext());
webView = createWebViewSafely(getContext());

Check warning

Code scanning / CodeQL

Android WebView settings allows access to content links Medium

Sensitive information may be exposed via a malicious link due to access to content:// links being allowed in this WebView.
if (webView == null) {
dismissAllowingStateLoss();
return null;
}
webView.setId(R.id.webView);

webView.createWithHtml(this, htmlString);

if (orientationListener == null) {
Expand Down Expand Up @@ -324,7 +328,9 @@
*/
@Override
public void onStop() {
orientationListener.disable();
if (orientationListener != null) {
orientationListener.disable();
}

super.onStop();
}
Expand Down Expand Up @@ -747,6 +753,15 @@
return InAppLayout.CENTER;
}
}

private IterableWebView createWebViewSafely(Context context) {
try {
return new IterableWebView(context);

Check warning

Code scanning / CodeQL

Android WebView settings allows access to content links Medium

Sensitive information may be exposed via a malicious link due to access to content:// links being allowed in this WebView.
} catch (AndroidRuntimeException e) {
IterableLogger.e(TAG, "Failed to create WebView", e);
return null;
}
}
}

enum InAppLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private PendingIntent getPendingIntent(Context context, IterableNotificationData
if (button.openApp) {
IterableLogger.d(TAG, "Go through TrampolineActivity");
buttonIntent.setClass(context, IterableTrampolineActivity.class);
buttonIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
buttonIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pendingButtonIntent = PendingIntent.getActivity(context, buttonIntent.hashCode(),
buttonIntent, pendingIntentFlag);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex
trampolineActivityIntent.setClass(context, IterableTrampolineActivity.class);
trampolineActivityIntent.putExtras(extras);
trampolineActivityIntent.putExtra(IterableConstants.ITERABLE_DATA_ACTION_IDENTIFIER, IterableConstants.ITERABLE_ACTION_DEFAULT);
trampolineActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
trampolineActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

// Action buttons
if (notificationData.getActionButtons() != null) {
Expand Down
Loading