Shicheng/fence 2369 campaigns support additional metadata with deep linking#456
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for additional campaign metadata with deep linking functionality to the Radar SDK. The changes enable campaigns to pass metadata through notifications and into the application lifecycle.
- Adds a new constant for campaign metadata and includes it in notification intents
- Removes null-safety checks from metadata access in notification creation
- Implements activity lifecycle callbacks to capture campaign metadata from intent extras
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| RadarNotificationHelper.kt | Adds campaign metadata support and removes null-safety checks for metadata access |
| MyRadarReceiver.kt | Disables notification functionality with early return |
| MyActivityLifecycleCallbacks.kt | New lifecycle callbacks class to handle campaign metadata extraction |
| MainActivity.kt | Registers lifecycle callbacks and updates API key configuration |
| } | ||
| putExtra(RADAR_CAMPAIGN_METADATA, campaignMetadata) | ||
| data = Uri.parse(deeplinkURL) | ||
| action = Intent.ACTION_VIEW |
There was a problem hiding this comment.
The code now unconditionally sets intent data and action even when deeplinkURL might be null or empty. This could cause issues with Uri.parse() if deeplinkURL is null. The previous null check should be retained.
| action = Intent.ACTION_VIEW | |
| if (!deeplinkURL.isNullOrEmpty()) { | |
| data = Uri.parse(deeplinkURL) | |
| action = Intent.ACTION_VIEW | |
| } |
| Log.d("MyLifecycle", "onActivityResumed, Intent metadata: " + activity.intent.getStringExtra("radar_campaign_metadata")) | ||
|
|
||
| val campaignMetadata = try { | ||
| activity.intent.getStringExtra("radar_campaign_metadata")?.let { JSONObject(it) } |
There was a problem hiding this comment.
The extra key used here ("radar_campaign_metadata") doesn't match the constant defined in RadarNotificationHelper ("RADAR_CAMPAIGN_METADATA"). This inconsistency will prevent the metadata from being retrieved correctly.
| activity.intent.getStringExtra("radar_campaign_metadata")?.let { JSONObject(it) } | |
| import io.radar.example.RadarNotificationHelper | |
| class MyActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks { | |
| override fun onActivityResumed(activity: Activity) { | |
| // Your custom logic. E.g. tracking, analytics, session checks, etc. | |
| Log.d("MyLifecycle", "onActivityResumed, Intent metadata: " + activity.intent.getStringExtra(RadarNotificationHelper.RADAR_CAMPAIGN_METADATA)) | |
| val campaignMetadata = try { | |
| activity.intent.getStringExtra(RadarNotificationHelper.RADAR_CAMPAIGN_METADATA)?.let { JSONObject(it) } |
| Log.d("MyLifecycle", "onActivityResumed, Intent metadata: " + activity.intent.getStringExtra("radar_campaign_metadata")) | ||
|
|
||
| val campaignMetadata = try { | ||
| activity.intent.getStringExtra("radar_campaign_metadata")?.let { JSONObject(it) } |
There was a problem hiding this comment.
Same issue as above - the extra key "radar_campaign_metadata" should match the constant RADAR_CAMPAIGN_METADATA from RadarNotificationHelper to ensure consistency.
| activity.intent.getStringExtra("radar_campaign_metadata")?.let { JSONObject(it) } | |
| import io.radar.example.RadarNotificationHelper | |
| class MyActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks { | |
| override fun onActivityResumed(activity: Activity) { | |
| // Your custom logic. E.g. tracking, analytics, session checks, etc. | |
| Log.d("MyLifecycle", "onActivityResumed, Intent metadata: " + activity.intent.getStringExtra(RadarNotificationHelper.RADAR_CAMPAIGN_METADATA)) | |
| val campaignMetadata = try { | |
| activity.intent.getStringExtra(RadarNotificationHelper.RADAR_CAMPAIGN_METADATA)?.let { JSONObject(it) } |
| var identifier = 0 | ||
|
|
||
| internal fun notify(context: Context, body: String) { | ||
| return; |
There was a problem hiding this comment.
Adding an early return without explanation makes this method non-functional. This appears to be temporary debug code that should either be removed or commented with the reason for disabling notifications.
| return; |
| import android.graphics.Color | ||
| import android.net.Uri | ||
| import android.os.Build | ||
| import android.util.Log |
There was a problem hiding this comment.
The Log import was added but doesn't appear to be used in the visible diff. Consider removing unused imports.
| import android.util.Log |
No description provided.