Skip to content
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

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bd10279
task(SDK-4057) - Revamped Timer Notification Template
Anush-Shand Oct 30, 2024
3424ab9
task(SDK-4057) - Fixes name of service
Anush-Shand Oct 30, 2024
de2d3eb
task(SDK-4057) - Fixes a log
Anush-Shand Nov 11, 2024
c5cae07
task(SDK-4057) - Fixes TimerTemplateService
Anush-Shand Nov 11, 2024
1dc7c41
task(SDK-4057) - Refactors ManifestValidator
Anush-Shand Nov 11, 2024
91d462e
task(SDK-4057) - Removes redundant imports
Anush-Shand Nov 11, 2024
5e2b8ac
task(SDK-4057) - More refactoring of TimerTemplateService
Anush-Shand Nov 11, 2024
7eecabc
task(SDK-4057) - More refactoring
Anush-Shand Nov 11, 2024
84aa6b6
task(SDK-4057) - Adds logs and fixes warnings
Anush-Shand Nov 11, 2024
3a18744
task(SDK-4057) - Improves logs
Anush-Shand Nov 12, 2024
7a9d8ea
Rename .java to .kt
Anush-Shand Nov 12, 2024
65974f5
task(SDK-4057) - Convert ManifestValidator to kotlin
Anush-Shand Nov 12, 2024
06e8970
task(SDK-4057) - Refactors PushProviders.java
Anush-Shand Nov 12, 2024
3741aaf
Merge branch 'develop' into task/SDK-4057/fg_service_timer_template
Anush-Shand Nov 12, 2024
2e91fb8
task(SDK-4057) - Adds tests for ManifestValidator
Anush-Shand Nov 12, 2024
721143e
Merge branch 'develop' into task/SDK-4057/fg_service_timer_template
Anush-Shand Jan 9, 2025
a4e6d27
task(SDK-4057) - Refactors storePushNotification into 2 separate func…
Anush-Shand Jan 9, 2025
2e0ff59
task(SDK-4057) - Adds a log to help debugging
Anush-Shand Jan 14, 2025
0ce9afe
task(SDK-4057) - Improves log
Anush-Shand Jan 14, 2025
7660295
task(SDK-4057) - Stops service even if notif not in tray
Anush-Shand Jan 14, 2025
6d8f170
task(SDK-4057) - Stops service later
Anush-Shand Jan 14, 2025
fd878bf
task(SDK-4057) - Moves permissions to app's manifest instead of the SDK
Anush-Shand Jan 17, 2025
d8bda66
task(SDK-4057) - Reverts formatting
Anush-Shand Jan 20, 2025
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
2 changes: 2 additions & 0 deletions clevertap-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Required runtime permission to display notifications on Android 13 -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING"/>
Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Contributor Author

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


<application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.WorkerThread;
import androidx.core.app.NotificationCompat;

import com.clevertap.android.sdk.cryption.CryptHandler;
import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
Expand Down Expand Up @@ -3379,6 +3381,28 @@ public void renderPushNotificationOnCallerThread(@NonNull INotificationRenderer

}

@RestrictTo(Scope.LIBRARY_GROUP)
public NotificationCompat.Builder getPushNotificationOnCallerThread(@NonNull INotificationRenderer iNotificationRenderer, Context context,
Bundle extras) {
CleverTapInstanceConfig config = coreState.getConfig();
try {
synchronized (coreState.getPushProviders().getPushRenderingLock()) {
Copy link
Collaborator

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?

config.getLogger().verbose(config.getAccountId(),
"returning push on caller thread with id = " + Thread.currentThread().getId());
Copy link
Collaborator

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.

coreState.getPushProviders().setPushNotificationRenderer(iNotificationRenderer);
if (extras != null && extras.containsKey(Constants.PT_NOTIF_ID)) {
return coreState.getPushProviders()._getNotification(context, extras,
extras.getInt(Constants.PT_NOTIF_ID));
} else {
return coreState.getPushProviders()._getNotification(context, extras, Constants.EMPTY_NOTIFICATION_ID);
}
}
} catch (Throwable t) {
config.getLogger().debug(config.getAccountId(), "Failed to process getPushNotification()", t);
return null;
}
}

/**
* Retrieves a notification bitmap with a specified timeout and size constraint.
*
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Loading
Loading