# react-native-push-notification-pack **Repository Path**: cbbgs/react-native-push-notification-pack ## Basic Information - **Project Name**: react-native-push-notification-pack - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-18 - **Last Updated**: 2026-01-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # React Native Push Notification A React Native push notification library designed for the OpenHarmonyOS platform, providing comprehensive notification management functionality. ## Download and Usage ### npm ```bash npm install @react-native-oh-tpl/react-native-push-notification ``` ### yarn ```bash yarn add @react-native-oh-tpl/react-native-push-notification ``` The following code demonstrates the basic usage scenario of this library: When using it, the imported library name remains the same. ```jsx import PushNotification from '@react-native-oh-tpl/react-native-push-notification'; const sendBasicNotification = async () => { try { if (!PushNotification) { showAlert('Error', 'PushNotification module unavailable'); return; } const options = { title: 'This is a regular message', text: 'This is the content of the regular message', id: Date.now(), notificationType: NotificationType.TEXT, isFloatingIcon: true, sound: 'rawfile/sound.mp3', notificationSlotType: SlotType.SOCIAL_COMMUNICATION, }; const id = await PushNotification.localNotification(JSON.stringify(options)); if (id !== undefined) { console.info(`Basic notification sent with id: ${id}`); showAlert('Success', `Notification sent, ID: ${id}`); } else { console.error('Send basic notification failed'); showAlert('Failed', 'Sending notification failed'); } } catch (error) { console.error('Send basic notification failed:', error); showAlert('Exception', `Sending notification exception: ${error}`); } }; ``` #### ## Link | | Autolink Support | RN Framework Version | | -------------------------- | ------------ | ------ | | ~8.7.0 | No | 0.77 | | ~8.6.4 | Yes | 0.72 | | <= 8.6.3-0.4.17@deprecated | No | 0.72 | Projects using AutoLink need to be configured according to this document. Autolink framework guide: [https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/en/Autolinking.md](https://gitee.com/link?target=https%3A%2F%2Fgitcode.com%2Fopenharmony-sig%2Fohos_react_native%2Fblob%2Fmaster%2Fdocs%2Fen%2FAutolinking.md) Projects using AutoLink need to be configured according to this document. Autolink framework guide: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/en/Autolinking.md If your version supports Autolink and the project has already integrated Autolink, you can skip the ManualLink configuration.
ManualLink: This step is guidance for manually configuring native dependencies First, you need to open the HarmonyOS project `harmony` in DevEco Studio. ### 1. Add overrides field to `oh-package.json5` in the project root directory ```json { ... "overrides": { "@rnoh/react-native-openharmony" : "./react_native_openharmony" } } ``` ### 2. Introduce native code There are currently two methods: 1. Import via har package (this method will be deprecated after IDE完善相关功能, currently preferred method); 2. Directly link source code. Method 1: Import via har package (recommended) > [!TIP] har packages are located in the `harmony` folder of the third-party library installation path. Open `entry/oh-package.json5`, add the following dependencies: ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", "@react-native-ohos/react-native-fast-image": "file:../../node_modules/@react-native-oh-tpl/react-native-push-notification/harmony/push_notification.har" } ``` Click the `sync` button in the upper right corner Or execute in the terminal: ```bash cd entry ohpm install ``` Method 2: Directly link source code To use direct source code linking, please refer to [Direct Source Code Linking Instructions](/en/link-source-code.md) ### 3. Configure CMakeLists and introduce PushNotificationPackage > If using <= 8.6.3-0.4.17 version, please skip this chapter. Open `entry/src/main/cpp/CMakeLists.txt`, add: ```diff project(rnapp) cmake_minimum_required(VERSION 3.4.1) set(CMAKE_SKIP_BUILD_RPATH TRUE) set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") + set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") set(LOG_VERBOSITY_LEVEL 1) set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use add_compile_definitions(WITH_HITRACE_SYSTRACE) add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-push-notification/src/main/cpp" ./fast-image) # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") add_library(rnoh_app SHARED ${GENERATED_CPP_FILES} "./PackageProvider.cpp" "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" ) target_link_libraries(rnoh_app PUBLIC rnoh) # RNOH_BEGIN: manual_package_linking_2 target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) + target_link_libraries(rnoh_app PUBLIC rnoh_push_notification) # RNOH_END: manual_package_linking_2 ``` Open `entry/src/main/cpp/PackageProvider.cpp`, add: ```diff #include "RNOH/PackageProvider.h" #include "generated/RNOHGeneratedPackage.h" #include "SamplePackage.h" + #include "RTNPushNotificationPackage.h" using namespace rnoh; std::vector> PackageProvider::getPackages(Package::Context ctx) { return { std::make_shared(ctx), std::make_shared(ctx), + std::make_shared(ctx), }; } ``` ### 4. Introduce PushNotificationPackage on the ArkTs side Open `entry/src/main/ets/RNPackagesFactory.ts`, add: ```diff ... + import {PushNotificationPackage} from '@react-native-oh-tpl/react-native-push-notification/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), + new FastImagePackage(ctx) ]; } ```
#### Run Click the `sync` button in the upper right corner Or execute in the terminal: ```bash cd entry ohpm install ``` Then compile and run. ## Constraints and Limitations ### Compatibility To use this library, you need to use the correct React-Native and RNOH versions. Additionally, you need to use compatible DevEco Studio and phone ROM. Validated on the following versions: 1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; 2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71; 3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; ## Properties ### NotificationOptions - `id`: Notification ID - `showDeliveryTime`: Whether to show delivery time - `tapDismissed`: Whether notification is automatically cleared - `autoDeletedTime`: Time for automatic clearing - `wantAgent`: WantAgent encapsulates the app's behavioral intentions, triggered when notification is clicked - `extraInfo`: Extended parameters - `isAlertOnce`: Set whether there is only one notification reminder - `isStopwatch`: Whether to show elapsed time - `isCountDown`: Whether to show countdown time - `isFloatingIcon`: Whether to show status bar icon - `label`: Notification label - `smallIcon`: Small icon (Base64 encoded or resource path) - `largeIcon`: Large icon (Base64 encoded or resource path) - `lockscreenPicture`: Picture displayed on lock screen - `notificationType`: Notification type (TEXT, LONGTEXT, LINES, PICTURE, PROGRESS) - `title`: Notification title - `text`: Notification content - `additionalText`: Notification additional content - `briefText`: Summary content of notification - `longText`: Long text of notification - `expandedTitle`: Title when notification expands - `picture`: Picture for picture notification (Base64 encoded or resource path) - `fileName`: Download file name (progress bar notification) - `progressValue`: Download progress (progress bar notification) - `fireDate`: Scheduled notification trigger time - `actionButtons`: Array of notification buttons - `groupName`: Group notification name - `notificationSlotType`: Notification channel type - `repeatType`: Repeat type (minute, hour, day, week, month, time) - `repeatTime`: Repeat interval time - `repeatInterval`: Repeat interval (milliseconds) - `repeatCount`: Number of repeats (-1 means infinite repeat) ### NotificationType Enum - `TEXT`: Basic text notification - `LONGTEXT`: Long text notification - `LINES`: Multi-line text notification - `PICTURE`: Picture notification - `PROGRESS`: Progress bar notification ### SlotType Enum - `UNKNOWN_TYPE`: Unknown type - `SOCIAL_COMMUNICATION`: Social communication - `SERVICE_INFORMATION`: Service information - `CONTENT_INFORMATION`: Content information - `LIVE_VIEW`: Live viewing - `CUSTOMER_SERVICE`: Customer service - `OTHER_TYPES`: Other types ### SlotLevel Enum - `LEVEL_NONE`: No level - `LEVEL_MIN`: Minimum level - `LEVEL_LOW`: Low level - `LEVEL_DEFAULT`: Default level - `LEVEL_HIGH`: High level ## Static Methods | Method Name | Description | Parameters | | --------------------------------------- | ----------------------- | --------------------------------------------------- | | configure | Configure push notification service | options: (config: string) => void | | localNotification | Send local notification | details: string | | cancelLocalNotification | Cancel local notification with specified ID | notificationId: number | | cancelAllLocalNotifications | Cancel all local notifications | None | | setApplicationIconBadgeNumber | Set application icon badge number | number: number | | getApplicationIconBadgeNumber | Get application icon badge number | None | | clearBadge | Clear badge | None | | clearAllNotifications | Clear all notifications | None | | removeAllDeliveredNotifications | Remove all delivered notifications | None | | getDeliveredNotifications | Get list of delivered notifications | None | | getScheduledLocalNotifications | Get scheduled local notifications | None | | removeDeliveredNotifications | Remove delivered notification with specified ID | id: number | | getChannels | Get list of notification channels | None | | channelExists | Check if specified type channel exists | notificationType: SlotType | | createChannel | Create notification channel | channelType: SlotType | | channelBlocked | Check if specified type channel is blocked | channelType: SlotType | | deleteChannel | Delete notification channel | type: SlotType | | requestPermissions | Request notification permissions | None | | checkPermissions | Check notification permissions status | None | | openNotifictionSetting | Open notification settings page | None | | unregister | Unregister push service | None | | isConfigured | Check if configured | None | | popInitialNotification | Pop initial notification | want: Object | | createWantAgent | Create WantAgent | notificationId: number, actionType?: string | | registerActionButton | Register notification button action | actionId: string, action: () => void | | getPushToken | Get push token | None | ## License This project is based on [The MIT License (MIT)](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2FDylanVann%2Freact-native-fast-image%2Fblob%2Fmain%2FLICENSE). Feel free to enjoy and participate in the open source.