Skip to content

Commit 09a610f

Browse files
author
UnnatiCP
committed
Added doc for tracking notification clicks in android
Added doc for tracking notification clicks in android
1 parent 6922990 commit 09a610f

3 files changed

Lines changed: 64 additions & 15 deletions

File tree

docs/sdks/android/methods.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,15 @@ Here is how the topics dialog looks like:
666666
<!--Java-->
667667

668668
```java
669-
// get the locally stored notification.
670-
Set<Notification> = CleverPush.getInstance(this).getNotifications();
669+
// Get the locally stored notification.
670+
Set<Notification> notificationList = CleverPush.getInstance(this).getNotifications();
671671
```
672672

673673
<!--Kotlin-->
674674

675675
```kotlin
676-
// get the locally stored notification.
677-
CleverPush.getInstance(this).getNotifications()
676+
// Get the locally stored notifications
677+
val notificationList = CleverPush.getInstance(this).notifications
678678
```
679679

680680
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -684,22 +684,71 @@ CleverPush.getInstance(this).getNotifications()
684684
<!--Java-->
685685

686686
```java
687-
// get remote notification and local notification based on the boolean argument.
688-
// - if you pass boolean argument YES you will get the list of remote notification else you will get the locally stored notification.
687+
// Get remote notifications or local notifications based on the boolean argument.
688+
// - Pass `true` to get the list of remote notifications.
689+
// - Pass `false` to get the locally stored notifications.
689690
CleverPush.getInstance(this).getNotifications(true, new NotificationsCallbackListener() {
690691
@Override
691692
public void ready(Set<Notification> notifications) {
693+
// handle notifications
694+
}
695+
});
696+
```
697+
698+
<!--Kotlin-->
692699

700+
```kotlin
701+
// Get remote notifications or local notifications based on the boolean argument.
702+
// - Pass `true` to get the list of remote notifications.
703+
// - Pass `false` to get the locally stored notifications.
704+
CleverPush.getInstance(this).getNotifications(true) { notifications ->
705+
// handle notifications
706+
}
707+
```
708+
709+
<!--END_DOCUSAURUS_CODE_TABS-->
710+
711+
## Tracking Notification Clicks
712+
713+
To track when a user clicks on a notification from your custom notification inbox or list, use the `trackInboxClicked()` method available in the Notification class.
714+
715+
<!--DOCUSAURUS_CODE_TABS-->
716+
717+
<!--Java-->
718+
719+
```java
720+
Set<Notification> notificationList = CleverPush.getInstance(this).getNotifications();
721+
722+
for (Notification notification : notificationList) {
723+
// Track an notification click
724+
notification.trackInboxClicked(notification.getId());
725+
}
726+
727+
CleverPush.getInstance(this).getNotifications(true, new NotificationsCallbackListener() {
728+
@Override
729+
public void ready(Set<Notification> notifications) {
730+
for (Notification notification : notifications) {
731+
// Track an notification click
732+
notification.trackInboxClicked(notification.getId());
733+
}
693734
}
694735
});
695736
```
696737

697738
<!--Kotlin-->
698739

699740
```kotlin
700-
// get remote notification and local notification based on the boolean argument.
701-
// - if you pass boolean argument YES you will get the list of remote notification else you will get the locally stored notification.
702-
CleverPush.getInstance(this).getNotifications(true) { }
741+
val notificationList = CleverPush.getInstance(this).notifications
742+
743+
notificationList.forEach { notification ->
744+
notification.trackInboxClicked(notification.id)
745+
}
746+
747+
CleverPush.getInstance(this).getNotifications(true) { notifications ->
748+
notifications.forEach { notification ->
749+
notification.trackInboxClicked(notification.id)
750+
}
751+
}
703752
```
704753

705754
<!--END_DOCUSAURUS_CODE_TABS-->

docs/sdks/flutter/methods.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ title: Methods
77

88
To initialize the CleverPush SDK, use the following method.
99

10-
CLEVERPUSH_CHANNEL_ID (String): Your unique CleverPush channel ID. This ID is required to link the app with your CleverPush account.
10+
**CLEVERPUSH_CHANNEL_ID (String)**: Your unique CleverPush channel ID. This ID is required to link the app with your CleverPush account.
1111

12-
setInitializedHandler: A listener that handles the event when the CleverPush SDK initialization is completed. Returns success (bool) and an optional failureMessage (String?) if initialization fails.
12+
**setInitializedHandler**: A listener that handles the event when the CleverPush SDK initialization is completed. Returns success (bool) and an optional failureMessage (String?) if initialization fails.
1313

14-
setNotificationReceivedHandler: A listener that handles the event when a notification is received. The notificationReceived method is triggered with a CPNotificationReceivedResult object containing the details of the received notification. It fires when notifications have been received.
14+
**setNotificationReceivedHandler**: A listener that handles the event when a notification is received. The notificationReceived method is triggered with a CPNotificationReceivedResult object containing the details of the received notification. It fires when notifications have been received.
1515

16-
setNotificationOpenedHandler: A listener that handles the event when a notification is opened. The notificationOpened method is triggered with a CPNotificationReceivedResult object containing the details of the opened notification. It fires when notifications have been opened.
16+
**setNotificationOpenedHandler**: A listener that handles the event when a notification is opened. The notificationOpened method is triggered with a CPNotificationReceivedResult object containing the details of the opened notification. It fires when notifications have been opened.
1717

18-
setSubscribedHandler: A listener that handles the event when a user subscribes. The subscribed method is triggered with the subscriptionId. it fires when the user has successfully been subscribed.
18+
**setSubscribedHandler**: A listener that handles the event when a user subscribes. The subscribed method is triggered with the subscriptionId. it fires when the user has successfully been subscribed.
1919

2020

2121
```dart

docs/sdks/react-native/methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Methods
77

88
To initialize the CleverPush SDK, use the following method.
99

10-
CLEVERPUSH_CHANNEL_ID (String): Your unique CleverPush channel ID. This ID is required to link the app with your CleverPush account.
10+
**CLEVERPUSH_CHANNEL_ID (String)**: Your unique CleverPush channel ID. This ID is required to link the app with your CleverPush account.
1111

1212
**received**: A listener that handles the event when a notification is received. The notificationReceived method is triggered with a NotificationOpenedResult object containing the details of the received notification. It fires when notifications have been received.
1313

0 commit comments

Comments
 (0)