Skip to content

Commit

Permalink
task(SDK-4057) - Adds logs and fixes warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush-Shand committed Nov 11, 2024
1 parent 7eecabc commit 84aa6b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public boolean onActionButtonClick(final Context context, final Bundle extras, f
CleverTapInstanceConfig config = extras.getParcelable("config");

if (dismissOnClick != null && dismissOnClick.equalsIgnoreCase("true")) {
/**
* For input box remind CTA,pt_dismiss_on_click must be true to raise event
*/
// For input box remind CTA,pt_dismiss_on_click must be true to raise event
if (actionID != null && actionID.contains("remind")) {
Utils.raiseCleverTapEvent(context, config, extras);
}
Expand All @@ -40,6 +38,7 @@ public boolean onMessageReceived(final Context applicationContext, final Bundle
TemplateRenderer templateRenderer = new TemplateRenderer(applicationContext, message);
if (ManifestValidator.isComponentPresentInManifest(applicationContext, "com.clevertap.android.pushtemplates.TimerTemplateService", ManifestValidator.ComponentType.SERVICE)
&& templateRenderer.getTemplateType() == TemplateType.TIMER) {
PTLog.debug("Starting service for Timer Template");
Intent serviceIntent = new Intent(applicationContext, TimerTemplateService.class);
serviceIntent.putExtras(message);
ContextCompat.startForegroundService(applicationContext, serviceIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@ import android.os.IBinder
import androidx.core.app.NotificationCompat
import com.clevertap.android.sdk.CleverTapAPI
import com.clevertap.android.sdk.CleverTapInstanceConfig
import com.clevertap.android.sdk.Logger
import com.clevertap.android.sdk.pushnotification.PushNotificationUtil
import com.clevertap.android.sdk.task.CTExecutorFactory

class TimerTemplateService : Service() {
companion object {
private const val TAG = "TimerTemplateService"
}

@SuppressLint("WrongConstant")
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
val message = intent.extras ?: return super.onStartCommand(intent, flags, startId)
val templateRenderer = TemplateRenderer(this@TimerTemplateService, message)
Logger.v(TAG, "Running Timer Template Service")
PTLog.verbose("Running Timer Template Service")

val cleverTapAPI = CleverTapAPI.getGlobalInstance(
this@TimerTemplateService,
Expand All @@ -40,12 +35,12 @@ class TimerTemplateService : Service() {
it.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
val nb = it.build()
startForeground(templateRenderer.notificationId, nb)
Logger.v(TAG, "Started foreground service with notification ID: ${templateRenderer.notificationId}")
PTLog.verbose("Started foreground service with notification ID: ${templateRenderer.notificationId}")
} ?: run {
Logger.v(TAG, "NotificationBuilder is null.")
PTLog.verbose("NotificationBuilder is null.")
}
} catch (e: Exception) {
Logger.v(TAG, "Error while creating notification: ${e.localizedMessage}")
PTLog.verbose("Error while creating notification: ${e.localizedMessage}")
e.printStackTrace()
}
null
Expand Down

0 comments on commit 84aa6b6

Please sign in to comment.