Push Templates SDK helps you engage with your users using fancy push notification templates built specifically to work with CleverTap.
This library is in public beta, for any issues, queries and concerns please open a new issue here
- Add the dependencies to the
build.gradle
implementation 'com.clevertap.android:push-templates:0.0.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.8.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
- Add the Service to your
AndroidManifest.xml
<service
android:name="com.clevertap.pushtemplates.PushTemplateMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
- Add the Receiver to your
AndroidManifest.xml
<receiver
android:name="com.clevertap.pushtemplates.PushTemplateReceiver"
android:exported="false"
android:enabled="true">
</receiver>
- Add the dependencies to the
build.gradle
implementation 'com.clevertap.android:push-templates:0.0.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.8.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
- Add the Receiver to your
AndroidManifest.xml
<receiver
android:name="com.clevertap.pushtemplates.PushTemplateReceiver"
android:exported="false"
android:enabled="true">
</receiver>
- Add the following code in your custom FirebaseMessageService class
public class MyMessagingService extends FirebaseMessagingService {
Context context;
CleverTapAPI instance;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
try{
context = getApplicationContext();
if (remoteMessage.getData().size() > 0) {
Bundle extras = new Bundle();
for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
extras.putString(entry.getKey(), entry.getValue());
}
instance = CleverTapAPI.getDefaultInstance(getApplicationContext());
boolean processCleverTapPN = Utils.isPNFromCleverTap(extras);
if(processCleverTapPN){
String pt_id = extras.getString(Constants.PT_ID);
if(pt_id == null || pt_id.isEmpty()){
CleverTapAPI.createNotification(context,extras);
}else{
TemplateRenderer.setDebugLevel(2); //-1 for OFF, 0, for INFO, 2 for DEBUG, 3 for VERBOSE (errors)
TemplateRenderer.createNotification(context,extras);
}
}else{
//Other providers
}
}
}catch (Throwable throwable){
PTLog.verbose("Error parsing FCM payload",throwable);
}
}
}
While creating a Push Notification campaign on CleverTap, just follow the steps below -
- On the "WHAT" section pass any values in the "title" and "message" fields (NOTE: These will be ignored)
- Click on "Advanced" and then click on "Add pair" to add the Template Keys
- You can also add the above keys into one JSON object and use the
pt_json
key to fill in the values
- Send a test push and schedule!
Basic Template is the basic push notification received on apps.
(Expanded and unexpanded example)
Auto carousel is an automatic revolving carousel push notification.
(Expanded and unexpanded example)
Rating template lets your users give you feedback, this feedback is captures as an event in CleverTap with the rating as the event property so that it can later be actionable.
(Expanded and unexpanded example)
Product catalog template lets you show case different images of a product (or a product catalog) before the user can decide to click on the "BUY NOW" option which can take them directly to the product via deep links.
(Expanded and unexpanded example)
Five icons template is a sticky push notification with no text, just 5 icons and a close button which can help your users go directly to the functionality of their choice with a button's click.
Basic Template Keys | Description |
---|---|
pt_id* | Value - pt_basic |
pt_title* | Title |
pt_msg* | Message |
pt_big_img* | Image |
pt_ico* | Large Icon |
pt_bg | Background Color in HEX |
pt_title_clr | Title Color in HEX |
pt_msg_clr | Message Color in HEX |
pt_dl1 | One Deep Link (minimum) |
pt_json | Above keys in JSON format |
Auto Carousel Template Keys | Description |
---|---|
pt_id* | Value - pt_carousel |
pt_title* | Title |
pt_msg* | Message |
pt_dl1* | One Deep Link (minimum) |
pt_img1* | Image One |
pt_img2* | Image Two |
pt_img3* | Image Three |
pt_img4 | Image Four |
pt_img5 | Image Five |
pt_bg | Background Color in HEX |
pt_title_clr | Title Color in HEX |
pt_msg_clr | Message Color in HEX |
pt_msg_summary | Message line when Notification is expanded |
pt_json | Above keys in JSON format |
Rating Template Keys | Description |
---|---|
pt_id* | Value - pt_rating |
pt_title* | Title |
pt_msg* | Message |
pt_default_dl* | Default Deep Link for Push Notification |
pt_dl1* | Deep Link for first/all star(s) |
pt_dl2 | Deep Link for second star |
pt_dl3 | Deep Link for third star |
pt_dl4 | Deep Link for fourth star |
pt_dl5 | Deep Link for fifth star |
pt_bg | Background Color in HEX |
pt_title_clr | Title Color in HEX |
pt_msg_clr | Message Color in HEX |
pt_msg_summary | Message line when Notification is expanded |
pt_json | Above keys in JSON format |
Product Catalog Template Keys | Description |
---|---|
pt_id* | Value - pt_product_display |
pt_title* | Title |
pt_msg* | Message |
pt_img1* | Image One |
pt_img2* | Image Two |
pt_img3* | Image Three |
pt_bt1* | Big text for first image |
pt_bt2* | Big text for second image |
pt_bt3* | Big text for third image |
pt_st1* | Small text for first image |
pt_st2* | Small text for second image |
pt_st3* | Small text for third image |
pt_dl1* | Deep Link for first image |
pt_dl2* | Deep Link for second image |
pt_dl3* | Deep Link for third image |
pt_bg | Background Color in HEX |
pt_title_clr | Title Color in HEX |
pt_msg_clr | Message Color in HEX |
pt_json | Above keys in JSON format |
Five Icons Template Keys | Description |
---|---|
pt_id* | Value - pt_five_icons |
pt_img1* | Icon One |
pt_img2* | Icon Two |
pt_img3* | Icon Three |
pt_img4* | Icon Four |
pt_img5* | Icon Five |
pt_dl1* | Deep Link for first icon |
pt_dl2* | Deep Link for second icon |
pt_dl3* | Deep Link for third icon |
pt_dl4* | Deep Link for fourth icon |
pt_dl5* | Deep Link for fifth icon |
pt_json | Above keys in JSON format |
- (*) - Mandatory
pt_title
andpt_msg
in all the templates support HTML elements like bold<b>
, italics<i>
and underline<u>
Check out the Sample app
Your contributions are always welcome! Please have a look at the contribution guidelines first. 🎉
The MIT License (MIT) 2020. Please have a look at the LICENSE.md for more details.