-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task(SDK-4057) - Revamped Timer Notification Template #682
base: develop
Are you sure you want to change the base?
Conversation
- Refactors the code in PushProviders.java to make it more modular - Adds a service which will now show the timer template
- Adds logs
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to ask clients to put this permission as it might have some compliances on playstore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @CTLalit - this should be mentioned in the docs and needs to be optional. All the code related to FGS should be with a permission check with all cases handled properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Most SDK's are using these permissions and they are not as critical as like an AlarmManager, it was merged by default in the final manifest
Moving it to the app to be safe
@darshanclevertap @piyush-kukadiya @CTLalit
Options
|
@Anush-Shand - My suggestion is to go with option 1 - Call Placeholders can have the title & message while the image & timer loads. Once the image loads, we have the notification ID to update the notification. If you could share a demo video of this on Slack, it would help. Option 2 is risky because if some delay happens more than 4s, the app will crash. See the 2nd comment here -> https://stackoverflow.com/a/45047542/8301966 |
Bundle extras) { | ||
CleverTapInstanceConfig config = coreState.getConfig(); | ||
try { | ||
synchronized (coreState.getPushProviders().getPushRenderingLock()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid locking if there is only one push provider available?
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
try { | ||
synchronized (coreState.getPushProviders().getPushRenderingLock()) { | ||
config.getLogger().verbose(config.getAccountId(), | ||
"returning push on caller thread with id = " + Thread.currentThread().getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe print if its main thread.
if (nb != null) { | ||
return nb; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are masking the logic behind a nullable NotificationBuilder return method, ideally check from data itself if we should short circuit.
baseDatabaseManager.loadDBAdapter(context) | ||
.storeUninstallTimestamp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might cause lag on main thread, confirm that is not happening.
.storeUninstallTimestamp(); | ||
String pingFreq = extras.getString("pf", ""); | ||
if (!TextUtils.isEmpty(pingFreq)) { | ||
updatePingFrequencyIfNeeded(context, Integer.parseInt(pingFreq)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer.parseInt
can throw, make sure it is handled.
return ManifestValidator.isComponentPresentInManifest(applicationContext, "com.clevertap.android.pushtemplates.TimerTemplateService", ManifestValidator.ComponentType.SERVICE) | ||
&& templateType == TemplateType.TIMER | ||
&& areRevampedTimerTemplatePermissionsGranted(applicationContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templateType == TemplateType.TIMER
can be first condition so short circuit happens without much computation
} | ||
|
||
val intent = Intent(context, TimerTemplateService::class.java) | ||
context.stopService(intent) | ||
}, (delay - 100).toLong()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets see if we can solve for not using such a code in this task.
val cleverTapAPI = CleverTapAPI.getGlobalInstance( | ||
this@TimerTemplateService, | ||
PushNotificationUtil.getAccountIdFromNotificationBundle(message) | ||
) | ||
val config: CleverTapInstanceConfig? = cleverTapAPI?.coreState?.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we run this code inside the task itself?
<meta-data | ||
android:name="CLEVERTAP_ACCOUNT_ID" | ||
android:value="YOUR ACCT ID" /> | ||
android:value="TEST-4RW-944-876Z" /> | ||
<meta-data | ||
android:name="CLEVERTAP_TOKEN" | ||
android:value="YOUR ACCT TOKEN" /> | ||
android:value="TEST-44c-024" /> | ||
<meta-data | ||
android:name="CLEVERTAP_REGION" | ||
android:value="YOUR ACCT REGION"/> | ||
android:value="eu1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete these details
https://wizrocket.atlassian.net/browse/SDK-4057