Skip to content

Commit

Permalink
Merge pull request #847 from mixpanel/jared-receiver-api-check
Browse files Browse the repository at this point in the history
Only register Broadcast receiver on API Level 33+ and non-Instant Apps
  • Loading branch information
jaredmixpanel authored Sep 23, 2024
2 parents a661a10 + bc03cb4 commit 57b92c7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main/java/com/mixpanel/android/mpmetrics/MixpanelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.os.Bundle;
import androidx.core.content.ContextCompat;

import com.mixpanel.android.util.MPConstants.SessionReplay;
import com.mixpanel.android.util.MPLog;
import com.mixpanel.android.util.ProxyServerInteractor;

Expand Down Expand Up @@ -195,13 +194,17 @@ public class MixpanelAPI {
mMessages.removeResidualImageFiles(new File(mContext.getApplicationInfo().dataDir));
}

BroadcastReceiver sessionReplayReceiver = new SessionReplayBroadcastReceiver(this);
ContextCompat.registerReceiver(
mContext.getApplicationContext(),
sessionReplayReceiver,
SessionReplayBroadcastReceiver.INTENT_FILTER,
ContextCompat.RECEIVER_NOT_EXPORTED
);
// Event tracking integration w/ Session Replay SDK requires Android 13 or higher.
// It is also NOT supported in "Instant" apps
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !context.getPackageManager().isInstantApp()) {
BroadcastReceiver sessionReplayReceiver = new SessionReplayBroadcastReceiver(this);
ContextCompat.registerReceiver(
mContext.getApplicationContext(),
sessionReplayReceiver,
SessionReplayBroadcastReceiver.INTENT_FILTER,
ContextCompat.RECEIVER_NOT_EXPORTED
);
}
}

/**
Expand Down

0 comments on commit 57b92c7

Please sign in to comment.