React Native wrapper for the Custom App Inbox feature of CleverTap SDK
We support app badge with unread notifications count for iOS, and most of the Android devices.
IMPORTANT! For proper work on iOS you have to install CleverTap-iOS-SDK via Cocoapods.
Follow the CleverTap iOS Quickstart guide to install CleverTap-iOS-SDK via Cocoapods.
$ npm install react-native-clevertap-inbox --save
$ react-native link react-native-clevertap-inbox
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-clevertap-inbox
and add RNCleverTapInbox.xcodeproj
libRNCleverTapInbox.a
to your project’s Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.opsway.react.RNCleverTapInboxPackage;
to the imports at the top of the filenew RNCleverTapInboxPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-clevertap-inbox'
project(':react-native-clevertap-inbox').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-clevertap-inbox/android')
android/app/build.gradle
:
compile project(':react-native-clevertap-inbox')
import RNCleverTapInbox from 'react-native-clevertap-inbox';
//Initialize App Inbox
RNCleverTapInbox.initializeInbox();
//Get Inbox Message Count
RNCleverTapInbox.getInboxMessageCount().then(count => {
console.log('All messages count: ', count);
});
//Get Inbox Unread Count
RNCleverTapInbox.getInboxMessageUnreadCount().then(count => {
console.log('Unread messages count: ', count);
});
//Get All messages
RNCleverTapInbox.getAllInboxMessages().then((response: string) => {
const messages = JSON.parse(response);
console.log('All messages: ', messages);
});
//Get only Unread messages
RNCleverTapInbox.getUnreadInboxMessages().then((response: string) => {
const messages = JSON.parse(response);
console.log('All unread messages: ', messages);
});
//Mark all Unread messages as Read
RNCleverTapInbox.markReadAllUnreadInboxMessages().then((success: boolean) => {
success && console.log(`All unread messages marked as read!`);
});
//Mark Message as Read
RNCleverTapInbox.markReadInboxMessage(messageId: string).then((success: boolean) => {
success && console.log(`Message with id ${messageId} marked as read!`);
});
//Delete message from the Inbox
RNCleverTapInbox.deleteInboxMessage(messageId: string).then((success: boolean) => {
success && console.log(`Message with id ${messageId} deleted!`);
});