项目作者: opsway

项目描述 :
React Native wrapper for the Custom App Inbox feature of CleverTap SDK
高级语言: Objective-C
项目地址: git://github.com/opsway/react-native-clevertap-inbox.git
创建时间: 2019-02-28T19:19:22Z
项目社区:https://github.com/opsway/react-native-clevertap-inbox

开源协议:

下载



react-native-clevertap-inbox

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.

Requirements

Follow the CleverTap iOS Quickstart guide to install CleverTap-iOS-SDK via Cocoapods.

Getting started

$ npm install react-native-clevertap-inbox --save

Mostly automatic installation

$ react-native link react-native-clevertap-inbox

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-clevertap-inbox and add RNCleverTapInbox.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNCleverTapInbox.a to your project’s Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
    • Add import com.opsway.react.RNCleverTapInboxPackage; to the imports at the top of the file
    • Add new RNCleverTapInboxPackage() to the list returned by the getPackages() method
  2. Append the following lines to android/settings.gradle:
    1. include ':react-native-clevertap-inbox'
    2. project(':react-native-clevertap-inbox').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-clevertap-inbox/android')
  3. Insert the following lines inside the dependencies block in android/app/build.gradle:
    1. compile project(':react-native-clevertap-inbox')

Usage

  1. import RNCleverTapInbox from 'react-native-clevertap-inbox';
  2. //Initialize App Inbox
  3. RNCleverTapInbox.initializeInbox();
  4. //Get Inbox Message Count
  5. RNCleverTapInbox.getInboxMessageCount().then(count => {
  6. console.log('All messages count: ', count);
  7. });
  8. //Get Inbox Unread Count
  9. RNCleverTapInbox.getInboxMessageUnreadCount().then(count => {
  10. console.log('Unread messages count: ', count);
  11. });
  12. //Get All messages
  13. RNCleverTapInbox.getAllInboxMessages().then((response: string) => {
  14. const messages = JSON.parse(response);
  15. console.log('All messages: ', messages);
  16. });
  17. //Get only Unread messages
  18. RNCleverTapInbox.getUnreadInboxMessages().then((response: string) => {
  19. const messages = JSON.parse(response);
  20. console.log('All unread messages: ', messages);
  21. });
  22. //Mark all Unread messages as Read
  23. RNCleverTapInbox.markReadAllUnreadInboxMessages().then((success: boolean) => {
  24. success && console.log(`All unread messages marked as read!`);
  25. });
  26. //Mark Message as Read
  27. RNCleverTapInbox.markReadInboxMessage(messageId: string).then((success: boolean) => {
  28. success && console.log(`Message with id ${messageId} marked as read!`);
  29. });
  30. //Delete message from the Inbox
  31. RNCleverTapInbox.deleteInboxMessage(messageId: string).then((success: boolean) => {
  32. success && console.log(`Message with id ${messageId} deleted!`);
  33. });