├── .github └── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── feature_request.yml │ └── question.yml ├── .gitignore ├── InlineInApp.js ├── LICENSE.md ├── README.md ├── docs └── README.md ├── example ├── LICENSE ├── README.md ├── Screenshots │ ├── Android_1.png │ ├── Android_2.png │ ├── iOS_1.png │ └── iOS_2.png └── demoapp │ ├── .bundle │ └── config │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc.js │ ├── .watchmanconfig │ ├── Actions.js │ ├── App.tsx │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── Settings.js │ ├── __tests__ │ └── App.test.tsx │ ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── google-services.json │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── demoapp │ │ │ │ ├── MainActivity.kt │ │ │ │ └── MainApplication.kt │ │ │ └── res │ │ │ ├── drawable │ │ │ └── rn_edit_text_material.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── .xcode.env │ ├── NotificationService │ │ ├── Info.plist │ │ ├── NotificationService.entitlements │ │ └── NotificationService.swift │ ├── Podfile │ ├── demoapp.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── demoapp.xcscheme │ ├── demoapp.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── demoapp │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── PrivacyInfo.xcprivacy │ │ ├── demoapp.entitlements │ │ └── main.m │ └── demoappTests │ │ ├── Info.plist │ │ └── demoappTests.m │ ├── jest.config.js │ ├── logos.png │ ├── metro.config.js │ ├── package.json │ ├── tsconfig.json │ └── yarn.lock ├── index.d.ts ├── index.js ├── package.json ├── pushwoosh-react-native-plugin.podspec ├── react-native.config.js ├── scripts └── add_inbox_ios_resources.js └── src ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── pushwoosh │ │ └── reactnativeplugin │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pushwoosh │ │ └── reactnativeplugin │ │ ├── ConversionUtil.java │ │ ├── CustomFirebaseMessagingService.java │ │ ├── EventDispatcher.java │ │ ├── InboxUiStyleManager.java │ │ ├── InlineInAppManager.java │ │ ├── PushwooshNotificationServiceExtension.java │ │ ├── PushwooshPackage.java │ │ ├── PushwooshPlugin.java │ │ ├── RCTInlineInAppView.java │ │ └── internal │ │ └── ReactNativePluginProvider.java │ └── res │ └── values │ └── strings.xml └── ios └── PushwooshPlugin ├── PWEventDispatcher.h ├── PWEventDispatcher.m ├── PWInlineInAppManager.h ├── PWInlineInAppManager.m ├── Pushwoosh.h └── Pushwoosh.m /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: "🐞 Bug Report" 2 | description: "Report us a bug" 3 | title: "[Bug]: " 4 | labels: ["bug"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for taking the time to create this issue. 10 | 11 | The more detailed information filled below will help us to investigate the root cause of the issue faster and fix it. 12 | This form is for React Native Plugin only. If this is a bug for another platform or framework — please create the issue in the corresponded [repository](https://github.com/orgs/Pushwoosh/repositories). We appreciate your cooperation! 13 | - type: checkboxes 14 | id: rtfm 15 | attributes: 16 | label: Documentation 17 | description: "Have you checked the relevant integration guide: [Integrating React Native Plugin](https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin) which describes implementation process of the Pushwoosh SDK to your app and follow all the necessary steps?" 18 | options: 19 | - label: I've checked the guide, but it doesn't help me to resolve the issue. 20 | required: true 21 | - type: textarea 22 | id: description 23 | attributes: 24 | label: Description 25 | description: Short description of the issue. You can add screenshots and screencast to illustrate it. 26 | placeholder: "Example: When receiving a push with Rich Media in a closed app, Rich Media is not shown." 27 | validations: 28 | required: true 29 | - type: dropdown 30 | id: severity 31 | attributes: 32 | label: Bug severity 33 | description: | 34 | How do you rate the severity of this bug? 35 | For an objective assessment, please take into account how often this bug occurs in everyday app interaction, how serious the consequences of its occurrence (crash, warning, etc.), number of affected users, enviroment where it occurs (stage, production. etc.). 36 | options: 37 | - Low 38 | - Normal 39 | - High 40 | - Urgent 41 | validations: 42 | required: true 43 | - type: textarea 44 | id: repro-steps 45 | attributes: 46 | label: Steps to Reproduce 47 | description: Describe all the steps needed to reproduce the issue. If an issue is only reproducible under particular circumstances, put all required details here. E.g., if a push is not shown only for a specific API request, provide the full request body. Or, if an issue is reproducible with a particular Rich Media, deep link, etc. — specify it. 48 | placeholder: | 49 | 1. Open the app; 50 | 2. Switch it to the background; 51 | 3. Received notification with "root_params" causes the app to crash. 52 | This happens only if dependency XYZ v.1.2.3 is installed 53 | validations: 54 | required: true 55 | - type: dropdown 56 | id: affected-version 57 | attributes: 58 | label: Your Pushwoosh React Native Plugin version 59 | description: Your React Native Plugin version which was integrated to the app. You may find it on the [releases page](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases) 60 | options: 61 | - 6.1.39 62 | - 6.1.38 63 | - 6.1.37 64 | - 6.1.36 65 | - 6.1.35 66 | - 6.1.34 67 | - 6.1.32 68 | - 6.1.31 69 | - 6.1.30 70 | - 6.1.29 71 | - 6.1.28 72 | - 6.1.27 73 | - 6.1.26 74 | - 6.1.25 75 | - 6.1.23 76 | - 6.1.22 77 | - 6.1.21 78 | - 6.1.20 79 | - 6.1.19 80 | - 6.1.18 81 | - 6.1.17 82 | - 6.1.16 83 | - 6.1.15 84 | - 6.1.14 85 | - 6.1.13 86 | - 6.1.12 87 | - 6.1.11 88 | - 6.1.10 89 | - 6.1.9 90 | - 6.1.8 91 | - 6.1.7 92 | - 6.1.6 93 | - 6.1.5 94 | - 6.1.4 95 | - 6.1.3 96 | - 6.1.2 97 | - 6.1.1 98 | - 6.0.10 99 | - 6.0.9 100 | - 6.0.8 101 | - 6.0.7 102 | - 6.0.6 103 | - 6.0.5 104 | - 6.0.4 105 | - 6.0.3 106 | - 6.0.2 107 | - 6.0.1 108 | - 6.0.0 109 | - Other — specify it in the description 110 | validations: 111 | required: true 112 | - type: input 113 | id: last-worked 114 | attributes: 115 | label: Last worked Pushwoosh React Native Plugin version (if any) 116 | description: Is there a version that worked well? If so, please specify. 117 | - type: checkboxes 118 | id: platforms-affected 119 | attributes: 120 | label: Affected platforms 121 | description: Select the platforms on which the issue occurs. This helps us determine whether the root cause is core plugin or platform specific. 122 | options: 123 | - label: Android 124 | - label: iOS 125 | validations: 126 | required: true 127 | - type: textarea 128 | id: platform-versions 129 | attributes: 130 | label: Affected OS versions and/or devices 131 | description: Please specify device models and custom distributions (if any) on which this issue occurs. If the issue occurs when building, then specify the target platform. 132 | placeholder: | 133 | E.g. Android 13 on a Google Pixel 3a XL, 134 | iOS 17.0.3 on an iPhone 14 135 | MIUI 14.0.8.0 on Xiaomi 13 Ultra, etc. 136 | validations: 137 | required: true 138 | - type: textarea 139 | id: workaround 140 | attributes: 141 | label: Workaround 142 | description: Have you found a workaround for this issue? Please tell us — this may help other people to continue their work while waiting for this issue to be resolved. 143 | - type: textarea 144 | id: logs 145 | attributes: 146 | label: Relevant log output 147 | description: After reproducing the issue, copy device console logs and paste them here "as is". This code block will be formatted automatically, so no additional formatting is needed. If the issue occurs when building, then provide us building logs here. 148 | render: shell 149 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: "💡 Feature request" 2 | description: "Suggest us a good idea or improvement" 3 | title: "[Feature]: " 4 | labels: ["feature"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for taking the time to create this request. 10 | 11 | This form is for React Native Plugin only. If this is a feature for another platform or framework — please create it in the corresponded [repository](https://github.com/orgs/Pushwoosh/repositories). We appreciate your cooperation! 12 | 13 | - type: textarea 14 | id: description 15 | attributes: 16 | label: Description 17 | description: Please tell us what's on your mind. You can add screenshots and screencast to illustrate your request. 18 | validations: 19 | required: true 20 | 21 | - type: textarea 22 | id: suggestions 23 | attributes: 24 | label: Sugeestions 25 | description: | 26 | If you know how you can achieve what you want or you have any information that may help us to achieve this, you can add it here. 27 | For example, links to repositories, discussion threads, documentation, code samples, etc. 28 | 29 | - type: markdown 30 | attributes: 31 | value: Thank you for your feedback! 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | name: "❓ Question" 2 | description: "Ask us a question" 3 | title: "[Question]: " 4 | labels: ["question"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for your question! 10 | 11 | This form is for React Native Plugin only. If this is a question for another platform or framework — please create it in the corresponded [repository](https://github.com/orgs/Pushwoosh/repositories). We appreciate your cooperation! 12 | 13 | - type: checkboxes 14 | id: rtfm 15 | attributes: 16 | label: Documentation 17 | description: "Have you checked the relevant integration guide: [Integrating React Native Plugin](https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin) which describes implementation process of the Pushwoosh SDK to your app and follow all the necessary steps?" 18 | options: 19 | - label: I've checked the guide, but I didn't find the information I needed there. 20 | required: true 21 | 22 | - type: textarea 23 | id: question 24 | attributes: 25 | label: Question 26 | description: How can we help you? Do you have any questions about the integration of the SDK or how it works? You can add screenshots and screencast to illustrate your request. 27 | validations: 28 | required: true 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | android/app/libs 43 | *.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/Preview.html 54 | fastlane/screenshots 55 | package-lock.json 56 | -------------------------------------------------------------------------------- /InlineInApp.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types'; 2 | import React from 'react'; 3 | import {requireNativeComponent} from 'react-native'; 4 | 5 | class InlineInAppView extends React.Component { 6 | _onLoaded = (event) => { 7 | if (!this.props.onLoaded) { 8 | return; 9 | } 10 | 11 | // process raw event... 12 | this.props.onLoaded(event.nativeEvent); 13 | } 14 | 15 | _onClosed = (event) => { 16 | if (!this.props.onClosed) { 17 | return; 18 | } 19 | 20 | // process raw event... 21 | this.props.onClosed(event.nativeEvent); 22 | } 23 | 24 | _onSizeChanged = (event) => { 25 | if (!this.props.onSizeChanged) { 26 | return; 27 | } 28 | 29 | // process raw event... 30 | this.props.onSizeChanged(event.nativeEvent); 31 | } 32 | 33 | render() { 34 | return ( 35 | 41 | ); 42 | } 43 | } 44 | 45 | InlineInAppView.propTypes = { 46 | /** 47 | * Value of the identifier property must be equal to the 48 | * identifier attribute value of the in-app message you've 49 | * created in Pushwoosh Control Panel 50 | */ 51 | identifier: PropTypes.string, 52 | /** 53 | * This event is called to notify you that an inline in-app 54 | * was loaded and has been added to the view 55 | */ 56 | onLoaded: PropTypes.func, 57 | /** 58 | * This event is called to notify you that an inline in-app 59 | * view has been closed by the user 60 | */ 61 | onClosed: PropTypes.func, 62 | /** 63 | * This event is called to notify you that an inline in-app 64 | * view size has been changed 65 | */ 66 | onSizeChanged: PropTypes.func, 67 | }; 68 | 69 | var PWInlineInAppView = requireNativeComponent('PWInlineInAppView', InlineInAppView) 70 | 71 | export default InlineInAppView -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Pushwoosh (http://www.pushwoosh.com) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | (i) the original and/or modified Software should be used exclusively to work with Pushwoosh services, 12 | 13 | (ii) the above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | React Native Pushwoosh Push Notifications module 2 | =================================================== 3 | 4 | [![GitHub release](https://img.shields.io/github/release/Pushwoosh/pushwoosh-react-native-plugin.svg?style=flat-square)](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases) 5 | [![npm](https://img.shields.io/npm/v/pushwoosh-react-native-plugin.svg)](https://www.npmjs.com/package/pushwoosh-react-native-plugin) 6 | [![license](https://img.shields.io/npm/l/pushwoosh-react-native-plugin.svg)](https://www.npmjs.com/package/pushwoosh-react-native-plugin) 7 | 8 | ![platforms](https://img.shields.io/badge/platforms-Android%20%7C%20iOS-yellowgreen.svg) 9 | 10 | | [Guide](https://www.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin) | [Documentation](docs/README.md) | [Sample](https://github.com/Pushwoosh/pushwoosh-react-native-sample) | 11 | | ----------------------------------------------------------- | ------------------------------- | -------------------------------------------------------------------- | 12 | 13 | 14 | ### Installation 15 | ``` 16 | npm install pushwoosh-react-native-plugin --save 17 | react-native link pushwoosh-react-native-plugin 18 | ``` 19 | 20 | For Android platform, also add the following lines to your project's build.gradle: 21 | 22 | ``` 23 | //you should already have buildscript and dependencies blocks in your project's build.gradle so just put the classpath line there 24 | buildscript { 25 | dependencies { 26 | classpath 'com.google.gms:google-services:4.3.3' 27 | } 28 | } 29 | 30 | //add these lines to the very end of your build.gradle 31 | apply { 32 | plugin com.google.gms.googleservices.GoogleServicesPlugin 33 | } 34 | ``` 35 | 36 | ### Usage 37 | 38 | ```js 39 | import Pushwoosh from 'pushwoosh-react-native-plugin'; 40 | 41 | Pushwoosh.init({ 42 | "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" , 43 | "project_number" : "YOUR_GCM_PROJECT_NUMBER" 44 | }); 45 | Pushwoosh.register(); 46 | ``` 47 | 48 | In order to use custom notification handling on iOS specify the parameter "pw_notification_handling" to "CUSTOM" when initializing the plugin(If no value specified Pushwoosh notification handler is used): 49 | 50 | ```js 51 | import Pushwoosh from 'pushwoosh-react-native-plugin'; 52 | 53 | Pushwoosh.init({ 54 | "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" , 55 | "project_number" : "YOUR_GCM_PROJECT_NUMBER", 56 | "pw_notification_handling" : "CUSTOM" 57 | }); 58 | Pushwoosh.register(); 59 | ``` 60 | 61 | In order to use reverse proxy to connect to pushwoosh servers specify the parameter "reverse_proxy_url" with the url to your reverse proxy when initializing the plugin: 62 | 63 | ```js 64 | import Pushwoosh from 'pushwoosh-react-native-plugin'; 65 | 66 | Pushwoosh.init({ 67 | "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" , 68 | "project_number" : "YOUR_GCM_PROJECT_NUMBER", 69 | "reverse_proxy_url" : "URL_TO_YOUR_REVERSE_PROXY" 70 | }); 71 | Pushwoosh.register(); 72 | ``` 73 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Pushwoosh React Native Module # 3 | 4 | Provides module for React Native to receive and handle push notifications for iOS and Android. 5 | 6 | Example: 7 | 8 | ```js 9 | var Pushwoosh = require('pushwoosh-react-native-plugin'); 10 | 11 | Pushwoosh.init({ "pw_appid" : "PUSHWOOSH_APP_ID" , "project_number" : "GOOGLE_PROJECT_NUMBER" }); 12 | 13 | Pushwoosh.register( 14 | (token) => { 15 | console.warn("Registered for push notifications with token: " + token); 16 | }, 17 | (error) => { 18 | console.warn("Failed to register for push notifications: " + error); 19 | } 20 | ); 21 | 22 | // this event is fired when the push is received in the app 23 | DeviceEventEmitter.addListener('pushReceived', (e: Event) => { 24 | console.warn("pushReceived: " + JSON.stringify(e)); 25 | }); 26 | 27 | // this event is fired when user clicks on notification 28 | DeviceEventEmitter.addListener('pushOpened', (e: Event) => { 29 | console.warn("pushOpened: " + JSON.stringify(e)); 30 | }); 31 | ``` 32 | 33 |
34 |

Summary

35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
Functions
init(config, success, fail)
register(success, fail)
unregister(success, fail)
setTags(tags, success, fail)
getTags(success, fail)
getPushToken(success)
getHwid(success)
setUserId(userId, success, fail)
postEvent(event, attributes)
setApplicationIconBadgeNumber(badgeNumber)
getApplicationIconBadgeNumber(callback)
addToApplicationIconBadgeNumber(badgeNumber)
setMultiNotificationMode(on)
setLightScreenOnNotification(on)
setEnableLED(on)
setColorLED(color)
setSoundType(type)
setVibrateType(type)
presentInboxUI()
showGDPRConsentUI()
showGDPRDeletionUI()
setCommunicationEnabled()
removeAllDeviceData()
enableHuaweiPushNotifications()
Events
pushOpened
pushReceived
72 |
73 | 74 | 75 | ### init 76 | 77 | ```js 78 | init(config, success, fail) 79 | ``` 80 | 81 | Initializes Pushwoosh module with application id and google project number. 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |
Parameters
objectconfigPushwoosh initialization config.
stringconfig.pw_appidPushwoosh application id.
stringconfig.project_numberGCM project number (for Android push notifications).
stringconfig.reverse_proxy_url(optional) Url to your reverse proxy.
stringconfig.pw_notification_handling(optional) To use custom notification handling on iOS specify the parameter "pw_notification_handling" to "CUSTOM".
functionsuccess(optional) initialization success callback.
functionfail(optional) initialization failure callback.
102 | 103 | ### register 104 | 105 | ```js 106 | register(success, fail) 107 | ``` 108 | 109 | Registers current device for push notifications. 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 |
Parameters
functionsuccess(optional) registration success callback. Receives push token as parameter.
functionfail(optional) registration failure callback.
126 | 127 | NOTE: if user does not allow application to receive push notifications and `UIBackgroundModes remote-notificaion` is not set in **Info.plist** none of these callbacks will be called. 128 | 129 | 130 | ### unregister 131 | 132 | ```js 133 | unregister(success, fail) 134 | ``` 135 | 136 | Unregisters current deivce from receiving push notifications. 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 |
Parameters
functionsuccess(optional) deregistration success callback.
functionfail(optional) deregistration failure callback.
153 | 154 | 155 | ### setTags 156 | 157 | ```js 158 | setTags(tags, success, fail) 159 | ``` 160 | 161 | Set tags associated with current device and application. 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
Parameters
objecttagsTags associated with current device.
functionsuccess(optional) method success callback.
functionfail(optional) method failure callback.
178 | 179 | Example: 180 | 181 | ```js 182 | pushNotification.setTags({ "string_tag" : "Hello world", "int_tag" : 42, "list_tag":["hello", "world"]}); 183 | ``` 184 | 185 | 186 | ### getTags 187 | 188 | ```js 189 | getTags(success, fail) 190 | ``` 191 | 192 | Get tags associated with current device and application. 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
Parameters
functionsuccess(optional) method success callback. Receives object containing tags as parameter.
functionfail(optional) method failure callback.
208 | 209 | Example: 210 | 211 | ```js 212 | Pushwoosh.getTags( 213 | function(tags) 214 | { 215 | console.warn('tags for the device: ' + JSON.stringify(tags)); 216 | }, 217 | function(error) 218 | { 219 | console.warn('get tags error: ' + JSON.stringify(error)); 220 | } 221 | ); 222 | ``` 223 | 224 | 225 | ### getPushToken 226 | 227 | ```js 228 | getPushToken(success) 229 | ``` 230 | 231 | Returns push token or null if device is not registered for push notifications. 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 |
Parameters
functionsuccessMethod success callback. Receives push token as parameter.
246 | 247 | 248 | ### getHwid 249 | 250 | ```js 251 | getHwid(success) 252 | ``` 253 | 254 | Returns Pushwoosh HWID used for communications with Pushwoosh API. 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 |
Parameters
functionsuccessMethod success callback. Receives Pushwoosh HWID as parameter.
269 | 270 | 271 | ### setUserId 272 | 273 | ```js 274 | setUserId(userId, success, fail) 275 | ``` 276 | 277 | Set User indentifier. This could be Facebook ID, username or email, or any other user ID. 278 | This allows data and events to be matched across multiple user devices. 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 |
Parameters
stringuserIdIdentifier of currently logged in user
functionsuccess(optional) method success callback.
functionfail(optional) method failure callback.
295 | 296 | 297 | ### postEvent 298 | 299 | ```js 300 | postEvent(event, attributes) 301 | ``` 302 | 303 | Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel. 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 |
Parameters
stringeventEvent name.
objectattributesAdditional event data.
319 | 320 | 321 | Example: 322 | 323 | ```js 324 | Pushwoosh.postEvent("buttonPressed", { "buttonNumber" : "4", "buttonLabel" : "Banner" }) 325 | ``` 326 | 327 | 328 | ### setApplicationIconBadgeNumber 329 | 330 | ```js 331 | setApplicationIconBadgeNumber(badgeNumber) 332 | ``` 333 | **[android, ios]** 334 | Set application icon badge number. 335 | 336 | |Parameter|Description| 337 | |-|-| 338 | |badgeNumber|Icon badge number| 339 | 340 | 341 | ### getApplicationIconBadgeNumber 342 | 343 | ```js 344 | getApplicationIconBadgeNumber(callback: Function) 345 | ``` 346 | **[android, ios]** 347 | Returns application icon badge number. 348 | 349 | 350 | ### addToApplicationIconBadgeNumber 351 | 352 | ```js 353 | addToApplicationIconBadgeNumber(badgeNumber: number) 354 | ``` 355 | **[android, ios]** 356 | Adds value to application icon badge. 357 | 358 | |Parameter|Description| 359 | |-|-| 360 | |badgeNumber|Incremental icon badge number| 361 | 362 | 363 | ### setMultiNotificationMode 364 | 365 | ```js 366 | setMultiNotificationMode(on: boolean) 367 | ``` 368 | **[android]** 369 | Allows multiple notifications to be displayed in the Android Notification Center. 370 | 371 | |Parameter|Description| 372 | |-|-| 373 | |on|Enable/disable multiple notifications (is disabled by default)| 374 | 375 | 376 | ### setLightScreenOnNotification 377 | 378 | ```js 379 | setLightScreenOnNotification(on: boolean) 380 | ``` 381 | **[android]** 382 | Turns screen on when notification arrives. 383 | 384 | |Parameter|Description| 385 | |-|-| 386 | |on|Enable/disable screen unlock (is disabled by default)| 387 | 388 | 389 | ### setEnableLED 390 | 391 | ```js 392 | setEnableLED(on: boolean) 393 | ``` 394 | **[android]** 395 | Enables LED blinking when notification arrives and display is off. 396 | 397 | |Parameter|Description| 398 | |-|-| 399 | |on|Enable/disable LED blink (disabled by default)| 400 | 401 | 402 | ### setColorLED 403 | 404 | ```js 405 | setColorLED(color: number) 406 | ``` 407 | **[android]** 408 | Set led color. Use with [setEnableLED](#setenableled). 409 | 410 | |Parameter|Description| 411 | |-|-| 412 | |color|LED color in ARGB integer format| 413 | 414 | 415 | ### setSoundType 416 | 417 | ```js 418 | setSoundType(type: number) 419 | ``` 420 | **[android]** 421 | Sets default sound for incoming push notifications. 422 | 423 | |Parameter|Description| 424 | |-|-| 425 | |type|Sound type (0 – default, 1 – no sound, 2 – always)| 426 | 427 | 428 | ### setVibrateType 429 | 430 | ```js 431 | setVibrateType(type: number) 432 | ``` 433 | **[android]** 434 | Sets default vibration mode for incoming push notifications. 435 | 436 | |Parameter|Description| 437 | |-|-| 438 | |type|Vibration type (0 – default, 1 – no vibration, 2 – always)| 439 | 440 | ### presentInboxUI 441 | 442 | ```js 443 | presentInboxUI() 444 | ``` 445 | 446 | Opens [Inbox](https://www.pushwoosh.com/docs/message-inbox) screen. 447 | 448 | Before using Message Inbox, please add node_modules/pushwoosh-react-native-plugin/src/ios/PushwooshInboxBundle.bundle to your project. Or, launch a script 'node node_modules/pushwoosh-react-native-plugin/scripts/add_inbox_ios_resources.js' to do it. 449 | 450 | 451 | ### showGDPRConsentUI 452 | 453 | ```js 454 | showGDPRConsentUI() 455 | ``` 456 | **[android, ios]** 457 | A part of [The GDPR Compliance](https://www.pushwoosh.com/docs/the-gdpr-compliance) solution that shows the GDPR Consent Form, ensuring lawful basis for processing personal data of EU citizens. 458 | 459 | 460 | ### showGDPRDeletionUI 461 | 462 | ```js 463 | showGDPRDeletionUI() 464 | ``` 465 | **[android, ios]** 466 | A part of [The GDPR Compliance](https://www.pushwoosh.com/docs/the-gdpr-compliance) solution that shows the GDPR Deletion Form, ensuring means to comply with the right to erasure. 467 | 468 | 469 | ### setCommunicationEnabled 470 | 471 | ```js 472 | setCommunicationEnabled(on: boolean) 473 | ``` 474 | **[android, ios]** 475 | A binary method enabling/disabling all communication with Pushwoosh. The boolean value is false unsubscribes the device from receiving push notifications and stops in-app messages download. The value true reverses the effect. 476 | 477 | 478 | ### removeAllDeviceData 479 | 480 | ```js 481 | removeAllDeviceData() 482 | ``` 483 | **[android, ios]** 484 | Removes all data about the device. Cannot be undone. 485 | 486 | ### enableHuaweiPushNotifications 487 | 488 | ```js 489 | enableHuaweiPushNotifications() 490 | ``` 491 | **[android]** 492 | Enables Huawei push messaging. Requires configured Huawei platform for your Pushwoosh application. See the integration guide. 493 | 494 | ### pushReceived 495 | 496 | ```js 497 | DeviceEventEmitter.addListener('pushReceived', (e: Event) => { 498 | console.warn("pushReceived: " + JSON.stringify(e)); 499 | // shows a push is received. Implement passive reaction to a push, such as UI update or data download. 500 | }); 501 | ``` 502 | **[android, ios]** 503 | Push notification received event is fired when push is received in app. 504 | 505 | 506 | ### pushOpened 507 | 508 | ```js 509 | DeviceEventEmitter.addListener('pushOpened', (e: Event) => { 510 | console.warn("pushOpened: " + JSON.stringify(e)); 511 | // shows a user tapped the notification. Implement user interaction, such as showing push details. 512 | }); 513 | ``` 514 | **[android, ios]** 515 | Push notification opened event is fired when user clicks on push notification. 516 | -------------------------------------------------------------------------------- /example/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Pushwoosh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # REACT NATIVE SAMPLE 2 | 3 | ## To launch and utilize a sample with Pushwoosh SDK integration, clone or download the repository archive. 4 | 5 | ### iOS 6 | Alt text Alt text 7 | 8 | ### Android 9 | Alt text Alt text 10 | 11 | ### 1. Open demoapp -> Settings.js and add your App ID and FCM Sender ID. 12 | 13 | ``` 14 | /** 15 | * initialize Pushwoosh SDK. 16 | * Example params: {"pw_appid": "application id", "project_number": "FCM sender id"} 17 | * 18 | * 1. app_id - YOUR_APP_ID 19 | * 2. sender_id - FCM_SENDER_ID 20 | */ 21 | 22 | Pushwoosh.init({ "pw_appid" : "XXXXX-XXXXX", "project_number":"XXXXXXXXXXXX"}); 23 | 24 | ``` 25 | 26 | ### 2. Add 'google-services.json' file in android -> app folder. 27 | 28 | ### 3. Add GoogleServices gradle plugin to your project's build.gradle 29 | 30 | ``` 31 | // you should already have buildscript and dependencies blocks in your project's build.gradle so just put the classpath line there 32 | 33 | buildscript { 34 | dependencies { 35 | classpath 'com.google.gms:google-services:4.3.3' 36 | } 37 | } 38 | 39 | ``` 40 | 41 | ### 4. Apply GoogleServicesPlugin in your app's build.gradle 42 | 43 | ``` 44 | // add these lines to the very end of your build.gradle 45 | 46 | apply { 47 | plugin com.google.gms.googleservices.GoogleServicesPlugin 48 | } 49 | 50 | ``` 51 | 52 | ## The guide for SDK integration is available on Pushwoosh [website](https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin). 53 | 54 | Documentation: 55 | https://github.com/Pushwoosh/pushwoosh-ios-sdk/tree/master/Documentation 56 | 57 | Pushwoosh team 58 | http://www.pushwoosh.com 59 | -------------------------------------------------------------------------------- /example/Screenshots/Android_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/Screenshots/Android_1.png -------------------------------------------------------------------------------- /example/Screenshots/Android_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/Screenshots/Android_2.png -------------------------------------------------------------------------------- /example/Screenshots/iOS_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/Screenshots/iOS_1.png -------------------------------------------------------------------------------- /example/Screenshots/iOS_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/Screenshots/iOS_2.png -------------------------------------------------------------------------------- /example/demoapp/.bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /example/demoapp/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native', 4 | }; 5 | -------------------------------------------------------------------------------- /example/demoapp/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | **/.xcode.env.local 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | *.hprof 33 | .cxx/ 34 | *.keystore 35 | !debug.keystore 36 | 37 | # node.js 38 | # 39 | node_modules/ 40 | npm-debug.log 41 | yarn-error.log 42 | 43 | # fastlane 44 | # 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 46 | # screenshots whenever they are needed. 47 | # For more information about the recommended setup visit: 48 | # https://docs.fastlane.tools/best-practices/source-control/ 49 | 50 | **/fastlane/report.xml 51 | **/fastlane/Preview.html 52 | **/fastlane/screenshots 53 | **/fastlane/test_output 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # Ruby / CocoaPods 59 | **/Pods/ 60 | /vendor/bundle/ 61 | 62 | # Temporary files created by Metro to check the health of the file watcher 63 | .metro-health-check* 64 | 65 | # testing 66 | /coverage 67 | 68 | # Yarn 69 | .yarn/* 70 | !.yarn/patches 71 | !.yarn/plugins 72 | !.yarn/releases 73 | !.yarn/sdks 74 | !.yarn/versions 75 | -------------------------------------------------------------------------------- /example/demoapp/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/demoapp/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /example/demoapp/Actions.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { View, StyleSheet, TextInput, ScrollView, TouchableOpacity, Text, Image, Alert } from 'react-native'; 3 | import Pushwoosh from 'pushwoosh-react-native-plugin'; 4 | 5 | const ButtonWithTextInput = ({ buttonText, onPress, placeholder1, placeholder2 }) => { 6 | const [inputValue1, setInputValue1] = useState(''); 7 | const [inputValue2, setInputValue2] = useState(''); 8 | 9 | const handlePress = () => { 10 | onPress(inputValue1, inputValue2); 11 | }; 12 | 13 | return ( 14 | 15 | 19 | {buttonText} 20 | 21 | {placeholder1 && ( 22 | setInputValue1(text)} 27 | /> 28 | )} 29 | {placeholder2 && ( 30 | setInputValue2(text)} 35 | /> 36 | )} 37 | 38 | ); 39 | }; 40 | 41 | const Button = ({ buttonText, onPress }) => { 42 | return ( 43 | 44 | 48 | {buttonText} 49 | 50 | 51 | ); 52 | }; 53 | 54 | const Actions = () => { 55 | return ( 56 | 57 | 58 | 62 | 63 | { 64 | /** 65 | * Set User indentifier. This could be Facebook ID, username or email, or any other user ID. 66 | * This allows data and events to be matched across multiple user devices. 67 | * 68 | * PUSHWOOSH CODE 69 | * | | 70 | * _| |_ 71 | * \ / 72 | * \ / 73 | * \_/ 74 | */ 75 | Pushwoosh.setUserId(inputValue1, 76 | () => { 77 | console.log("User ID was successfully set."); 78 | }, 79 | (error) => { 80 | console.error("Failed to set User ID:", error); 81 | } 82 | ); 83 | }} placeholder1="USER ID" /> 84 | 85 | { 86 | /** 87 | * Post events for In-App Messages. This can trigger In-App message HTML as specified in Pushwoosh Control Panel. 88 | * [event] is string name of the event 89 | * [attributes] is map contains additional event attributes 90 | * 91 | * PUSHWOOSH CODE 92 | * | | 93 | * _| |_ 94 | * \ / 95 | * \ / 96 | * \_/ 97 | */ 98 | Pushwoosh.postEvent(inputValue1, { attribute1: "value1", attribute2: "value2" }); 99 | }} placeholder1="EVENT NAME" /> 100 | 101 | { 102 | /** 103 | * setLanguage(language: string): void; method 104 | * 105 | * PUSHWOOSH CODE 106 | * | | 107 | * _| |_ 108 | * \ / 109 | * \ / 110 | * \_/ 111 | */ 112 | Pushwoosh.setLanguage(inputValue1); 113 | }} placeholder1="en" /> 114 | 115 | { 116 | /** 117 | * Associates device with given [tags]. If setTags request fails tags will be resent on the next application launch. 118 | * 119 | * PUSHWOOSH CODE 120 | * | | 121 | * _| |_ 122 | * \ / 123 | * \ / 124 | * \_/ 125 | */ 126 | Pushwoosh.setTags({ 'tags': inputValue1, 'value': inputValue2 }, 127 | () => { 128 | console.log("Tags were successfully set."); 129 | 130 | }, 131 | (error) => { 132 | console.error("Failed to set tags:", error); 133 | }); 134 | }} placeholder1="KEY" placeholder2="VALUE" /> 135 | 136 | { 137 | /** 138 | * SET USER EMAILS 139 | * setUserEmails(userId: string, emails: (string | string[]), success?: () => void, fail?: (error: Error) => void): void; 140 | * 141 | * PUSHWOOSH CODE 142 | * | | 143 | * _| |_ 144 | * \ / 145 | * \ / 146 | * \_/ 147 | */ 148 | Pushwoosh.setUserEmails( 149 | inputValue1, 150 | [inputValue2], 151 | () => { 152 | console.log("User emails were successfully set."); 153 | }, 154 | (error) => { 155 | console.error("Failed to set user emails:", error); 156 | } 157 | ); 158 | }} placeholder1="USER" placeholder2="EMAILS" /> 159 | { 160 | /** 161 | * SET EMAILS 162 | * setEmails(emails: (string | string[]), success?: () => void, fail?: (error: Error) => void): void; 163 | * 164 | * PUSHWOOSH CODE 165 | * | | 166 | * _| |_ 167 | * \ / 168 | * \ / 169 | * \_/ 170 | */ 171 | Pushwoosh.setEmails( [inputValue1], 172 | () => { 173 | console.log("Emails were successfully set."); 174 | }, 175 | (error) => { 176 | console.error("Failed to set emails:", error); 177 | } 178 | ); 179 | }} placeholder1="EMAILS" /> 180 | 181 |