├── .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 | [](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases)
5 | [](https://www.npmjs.com/package/pushwoosh-react-native-plugin)
6 | [](https://www.npmjs.com/package/pushwoosh-react-native-plugin)
7 |
8 | 
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 | Functions
40 |
41 | init(config, success, fail)
42 | register(success, fail)
43 | unregister(success, fail)
44 | setTags(tags, success, fail)
45 | getTags(success, fail)
46 | getPushToken(success)
47 | getHwid(success)
48 | setUserId(userId, success, fail)
49 | postEvent(event, attributes)
50 | setApplicationIconBadgeNumber(badgeNumber)
51 | getApplicationIconBadgeNumber(callback)
52 | addToApplicationIconBadgeNumber(badgeNumber)
53 | setMultiNotificationMode(on)
54 | setLightScreenOnNotification(on)
55 | setEnableLED(on)
56 | setColorLED(color)
57 | setSoundType(type)
58 | setVibrateType(type)
59 | presentInboxUI()
60 | showGDPRConsentUI()
61 | showGDPRDeletionUI()
62 | setCommunicationEnabled()
63 | removeAllDeviceData()
64 | enableHuaweiPushNotifications()
65 |
66 | Events
67 |
68 | pushOpened
69 | pushReceived
70 |
71 |
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 | Parameters
92 |
93 | object config Pushwoosh initialization config.
94 | string config.pw_appid Pushwoosh application id.
95 | string config.project_number GCM project number (for Android push notifications).
96 | string config.reverse_proxy_url (optional) Url to your reverse proxy.
97 | string config.pw_notification_handling (optional) To use custom notification handling on iOS specify the parameter "pw_notification_handling" to "CUSTOM".
98 | function success (optional) initialization success callback.
99 | function fail (optional) initialization failure callback.
100 |
101 |
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 | Parameters
121 |
122 | function success (optional) registration success callback. Receives push token as parameter.
123 | function fail (optional) registration failure callback.
124 |
125 |
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 | Parameters
148 |
149 | function success (optional) deregistration success callback.
150 | function fail (optional) deregistration failure callback.
151 |
152 |
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 | Parameters
172 |
173 | object tags Tags associated with current device.
174 | function success (optional) method success callback.
175 | function fail (optional) method failure callback.
176 |
177 |
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 | Parameters
203 |
204 | function success (optional) method success callback. Receives object containing tags as parameter.
205 | function fail (optional) method failure callback.
206 |
207 |
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 | Parameters
242 |
243 | function success Method success callback. Receives push token as parameter.
244 |
245 |
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 | Parameters
265 |
266 | function success Method success callback. Receives Pushwoosh HWID as parameter.
267 |
268 |
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 | Parameters
289 |
290 | string userId Identifier of currently logged in user
291 | function success (optional) method success callback.
292 | function fail (optional) method failure callback.
293 |
294 |
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 | Parameters
314 |
315 | string event Event name.
316 | object attributes Additional event data.
317 |
318 |
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 |
7 |
8 | ### Android
9 |
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 | {
182 | /**
183 | * Pushwoosh HWID associated with current device
184 | *
185 | * PUSHWOOSH CODE
186 | * | |
187 | * _| |_
188 | * \ /
189 | * \ /
190 | * \_/
191 | */
192 | Pushwoosh.getHwid((hwid) => {
193 | Alert.alert('HWID: ', hwid);
194 | });
195 | }}/>
196 |
197 | {
198 | /**
199 | * Push notification token or null if device is not registered yet.
200 | *
201 | * PUSHWOOSH CODE
202 | * | |
203 | * _| |_
204 | * \ /
205 | * \ /
206 | * \_/
207 | */
208 | Pushwoosh.getPushToken((token) => {
209 | Alert.alert('PUSH TOKEN: ', token);
210 | });
211 | }}/>
212 | {
213 | /**
214 | * GET USER ID
215 | *
216 | * PUSHWOOSH CODE
217 | * | |
218 | * _| |_
219 | * \ /
220 | * \ /
221 | * \_/
222 | */
223 | Pushwoosh.getUserId((userId) => {
224 | Alert.alert('USER ID: ', userId);
225 | });
226 | }}/>
227 | {
229 | /**
230 | * GET SHOW PUSH NOTIFICATION ALERT STATE
231 | *
232 | * PUSHWOOSH CODE
233 | * | |
234 | * _| |_
235 | * \ /
236 | * \ /
237 | * \_/
238 | */
239 | Pushwoosh.getShowPushnotificationAlert((willShow) => {
240 | if (willShow) {
241 | Alert.alert('PUSH NOTIFICATION ALERT ENABLED');
242 | } else {
243 | Alert.alert('PUSH NOTIFICATION ALERT DISABLED');
244 | }
245 | });
246 | }}
247 | />
248 |
249 | );
250 | };
251 |
252 | const styles = StyleSheet.create({
253 | container: {
254 | flexGrow: 1,
255 | backgroundColor: '#ffffff',
256 | alignItems: 'center',
257 | },
258 | header: {
259 | flexDirection: 'row',
260 | justifyContent: 'space-between',
261 | paddingHorizontal: 20,
262 | paddingVertical: 10,
263 | },
264 | textField: {
265 | borderWidth: 1,
266 | borderColor: '#cccccc',
267 | borderRadius: 5,
268 | padding: 10,
269 | },
270 | button: {
271 | backgroundColor: '#cccccc',
272 | borderRadius: 10,
273 | paddingVertical: 10,
274 | paddingHorizontal: 20,
275 | marginRight: 10,
276 | shadowColor: '#000',
277 | shadowOffset: {
278 | width: 0,
279 | height: 2,
280 | },
281 | shadowOpacity: 0.25,
282 | shadowRadius: 3.84,
283 | elevation: 5,
284 | },
285 | buttonText: {
286 | color: '#800080',
287 | fontWeight: 'bold',
288 | textAlign: 'center',
289 | },
290 | imageContainer: {
291 | justifyContent: 'center',
292 | alignItems: 'center',
293 | marginTop: 20,
294 | },
295 | image: {
296 | width: 75,
297 | height: 75,
298 | borderRadius: 20
299 | },
300 | });
301 |
302 | export default Actions;
303 |
--------------------------------------------------------------------------------
/example/demoapp/App.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | import React from 'react';
9 | import type {PropsWithChildren} from 'react';
10 | import {
11 | SafeAreaView,
12 | ScrollView,
13 | StatusBar,
14 | StyleSheet,
15 | Text,
16 | useColorScheme,
17 | View,
18 | } from 'react-native';
19 |
20 | import {
21 | Colors,
22 | DebugInstructions,
23 | Header,
24 | LearnMoreLinks,
25 | ReloadInstructions,
26 | } from 'react-native/Libraries/NewAppScreen';
27 |
28 | type SectionProps = PropsWithChildren<{
29 | title: string;
30 | }>;
31 |
32 | function Section({children, title}: SectionProps): React.JSX.Element {
33 | const isDarkMode = useColorScheme() === 'dark';
34 | return (
35 |
36 |
43 | {title}
44 |
45 |
52 | {children}
53 |
54 |
55 | );
56 | }
57 |
58 | function App(): React.JSX.Element {
59 | const isDarkMode = useColorScheme() === 'dark';
60 |
61 | const backgroundStyle = {
62 | backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
63 | };
64 |
65 | return (
66 |
67 |
71 |
74 |
75 |
79 |
80 | Edit App.tsx to change this
81 | screen and then come back to see your edits.
82 |
83 |
86 |
89 |
90 | Read the docs to discover what to do next:
91 |
92 |
93 |
94 |
95 |
96 | );
97 | }
98 |
99 | const styles = StyleSheet.create({
100 | sectionContainer: {
101 | marginTop: 32,
102 | paddingHorizontal: 24,
103 | },
104 | sectionTitle: {
105 | fontSize: 24,
106 | fontWeight: '600',
107 | },
108 | sectionDescription: {
109 | marginTop: 8,
110 | fontSize: 18,
111 | fontWeight: '400',
112 | },
113 | highlight: {
114 | fontWeight: '700',
115 | },
116 | });
117 |
118 | export default App;
119 |
--------------------------------------------------------------------------------
/example/demoapp/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby ">= 2.6.10"
5 |
6 | # Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
7 | # bound in the template on Cocoapods with next React Native release.
8 | gem 'cocoapods', '>= 1.13', '< 1.15'
9 | gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
10 |
--------------------------------------------------------------------------------
/example/demoapp/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.7)
5 | base64
6 | nkf
7 | rexml
8 | activesupport (6.1.7.7)
9 | concurrent-ruby (~> 1.0, >= 1.0.2)
10 | i18n (>= 1.6, < 2)
11 | minitest (>= 5.1)
12 | tzinfo (~> 2.0)
13 | zeitwerk (~> 2.3)
14 | addressable (2.8.6)
15 | public_suffix (>= 2.0.2, < 6.0)
16 | algoliasearch (1.27.5)
17 | httpclient (~> 2.8, >= 2.8.3)
18 | json (>= 1.5.1)
19 | atomos (0.1.3)
20 | base64 (0.2.0)
21 | claide (1.1.0)
22 | cocoapods (1.14.3)
23 | addressable (~> 2.8)
24 | claide (>= 1.0.2, < 2.0)
25 | cocoapods-core (= 1.14.3)
26 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
27 | cocoapods-downloader (>= 2.1, < 3.0)
28 | cocoapods-plugins (>= 1.0.0, < 2.0)
29 | cocoapods-search (>= 1.0.0, < 2.0)
30 | cocoapods-trunk (>= 1.6.0, < 2.0)
31 | cocoapods-try (>= 1.1.0, < 2.0)
32 | colored2 (~> 3.1)
33 | escape (~> 0.0.4)
34 | fourflusher (>= 2.3.0, < 3.0)
35 | gh_inspector (~> 1.0)
36 | molinillo (~> 0.8.0)
37 | nap (~> 1.0)
38 | ruby-macho (>= 2.3.0, < 3.0)
39 | xcodeproj (>= 1.23.0, < 2.0)
40 | cocoapods-core (1.14.3)
41 | activesupport (>= 5.0, < 8)
42 | addressable (~> 2.8)
43 | algoliasearch (~> 1.0)
44 | concurrent-ruby (~> 1.1)
45 | fuzzy_match (~> 2.0.4)
46 | nap (~> 1.0)
47 | netrc (~> 0.11)
48 | public_suffix (~> 4.0)
49 | typhoeus (~> 1.0)
50 | cocoapods-deintegrate (1.0.5)
51 | cocoapods-downloader (2.1)
52 | cocoapods-plugins (1.0.0)
53 | nap
54 | cocoapods-search (1.0.1)
55 | cocoapods-trunk (1.6.0)
56 | nap (>= 0.8, < 2.0)
57 | netrc (~> 0.11)
58 | cocoapods-try (1.2.0)
59 | colored2 (3.1.2)
60 | concurrent-ruby (1.2.3)
61 | escape (0.0.4)
62 | ethon (0.16.0)
63 | ffi (>= 1.15.0)
64 | ffi (1.16.3)
65 | fourflusher (2.3.1)
66 | fuzzy_match (2.0.4)
67 | gh_inspector (1.1.3)
68 | httpclient (2.8.3)
69 | i18n (1.14.5)
70 | concurrent-ruby (~> 1.0)
71 | json (2.7.2)
72 | minitest (5.22.3)
73 | molinillo (0.8.0)
74 | nanaimo (0.3.0)
75 | nap (1.1.0)
76 | netrc (0.11.0)
77 | nkf (0.2.0)
78 | public_suffix (4.0.7)
79 | rexml (3.2.6)
80 | ruby-macho (2.5.1)
81 | typhoeus (1.4.1)
82 | ethon (>= 0.9.0)
83 | tzinfo (2.0.6)
84 | concurrent-ruby (~> 1.0)
85 | xcodeproj (1.24.0)
86 | CFPropertyList (>= 2.3.3, < 4.0)
87 | atomos (~> 0.1.3)
88 | claide (>= 1.0.2, < 2.0)
89 | colored2 (~> 3.1)
90 | nanaimo (~> 0.3.0)
91 | rexml (~> 3.2.4)
92 | zeitwerk (2.6.14)
93 |
94 | PLATFORMS
95 | ruby
96 |
97 | DEPENDENCIES
98 | activesupport (>= 6.1.7.5, < 7.1.0)
99 | cocoapods (>= 1.13, < 1.15)
100 |
101 | RUBY VERSION
102 | ruby 2.6.10p210
103 |
104 | BUNDLED WITH
105 | 1.17.2
106 |
--------------------------------------------------------------------------------
/example/demoapp/README.md:
--------------------------------------------------------------------------------
1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2 |
3 | # Getting Started
4 |
5 | >**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6 |
7 | ## Step 1: Start the Metro Server
8 |
9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10 |
11 | To start Metro, run the following command from the _root_ of your React Native project:
12 |
13 | ```bash
14 | # using npm
15 | npm start
16 |
17 | # OR using Yarn
18 | yarn start
19 | ```
20 |
21 | ## Step 2: Start your Application
22 |
23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24 |
25 | ### For Android
26 |
27 | ```bash
28 | # using npm
29 | npm run android
30 |
31 | # OR using Yarn
32 | yarn android
33 | ```
34 |
35 | ### For iOS
36 |
37 | ```bash
38 | # using npm
39 | npm run ios
40 |
41 | # OR using Yarn
42 | yarn ios
43 | ```
44 |
45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46 |
47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48 |
49 | ## Step 3: Modifying your App
50 |
51 | Now that you have successfully run the app, let's modify it.
52 |
53 | 1. Open `App.tsx` in your text editor of choice and edit some lines.
54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!
55 |
56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!
57 |
58 | ## Congratulations! :tada:
59 |
60 | You've successfully run and modified your React Native App. :partying_face:
61 |
62 | ### Now what?
63 |
64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66 |
67 | # Troubleshooting
68 |
69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70 |
71 | # Learn More
72 |
73 | To learn more about React Native, take a look at the following resources:
74 |
75 | - [React Native Website](https://reactnative.dev) - learn more about React Native.
76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
80 |
--------------------------------------------------------------------------------
/example/demoapp/Settings.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import { View, Text, StyleSheet, Switch } from 'react-native';
3 | import Pushwoosh from 'pushwoosh-react-native-plugin';
4 |
5 | const Settings = () => {
6 | const [isEnabledRegister, setIsEnabledRegister] = useState(false);
7 | const [isEnabledServer, setIsEnabledServer] = useState(true);
8 |
9 | const toggleSwitchNotification = () => {
10 | setIsEnabledRegister(previousState => !previousState);
11 | };
12 |
13 | useEffect(() => {
14 | if (isEnabledRegister) {
15 | /**
16 | * initialize Pushwoosh SDK.
17 | * Example params: {"pw_appid": "application id", "project_number": "FCM sender id"}
18 | *
19 | * 1. app_id - YOUR_APP_ID
20 | * 2. sender_id - FCM_SENDER_ID
21 | */
22 | Pushwoosh.init({ "pw_appid" : "XXXXX-XXXXX", "project_number":"XXXXXXXXXXXX"});
23 |
24 | /**
25 | * To register for push notifications, call the following method:
26 | *
27 | * PUSHWOOSH CODE
28 | * | |
29 | * _| |_
30 | * \ /
31 | * \ /
32 | * \_/
33 | */
34 | Pushwoosh.register(
35 | (token) => {
36 | console.warn("Registered for pushes: " + token);
37 | Pushwoosh.getPushToken(function(token) {
38 | console.warn("Push token: " + token);
39 | });
40 | },
41 | (error) => {
42 | console.warn("Failed to register: " + error);
43 | }
44 | );
45 | } else {
46 | /**
47 | * To unregister for push notifications, call the following method:
48 | *
49 | * PUSHWOOSH CODE
50 | * | |
51 | * _| |_
52 | * \ /
53 | * \ /
54 | * \_/
55 | */
56 | Pushwoosh.unregister();
57 | }
58 | }, [isEnabledRegister]);
59 |
60 | const toggleSwitchServerCommunication = () => {
61 | setIsEnabledServer(previousState => !previousState);
62 | };
63 |
64 | useEffect(() => {
65 | if (isEnabledServer) {
66 | /**
67 | * Server Communication Enable = true
68 | */
69 | Pushwoosh.setCommunicationEnabled(true);
70 | } else {
71 | /**
72 | * Server Communication Enable = false
73 | */
74 | Pushwoosh.setCommunicationEnabled(false);
75 | }
76 | }, [isEnabledServer]);
77 |
78 | return (
79 |
80 |
81 | Register For Push Notifications
82 |
89 |
90 |
91 |
92 | Server Communication Enabled
93 |
100 |
101 |
102 |
103 | );
104 | };
105 |
106 | const styles = StyleSheet.create({
107 | container: {
108 | flex: 1,
109 | justifyContent: 'flex-start',
110 | alignItems: 'center',
111 | backgroundColor: '#ffffff',
112 | paddingTop: 20,
113 | },
114 | row: {
115 | flexDirection: 'row',
116 | alignItems: 'center',
117 | justifyContent: 'space-between',
118 | paddingHorizontal: 20,
119 | width: '100%',
120 | },
121 | label: {
122 | fontSize: 18,
123 | },
124 | });
125 |
126 | export default Settings;
127 |
--------------------------------------------------------------------------------
/example/demoapp/__tests__/App.test.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../App';
8 |
9 | // Note: import explicitly to use the types shipped with jest.
10 | import {it} from '@jest/globals';
11 |
12 | // Note: test renderer must be required after react-native.
13 | import renderer from 'react-test-renderer';
14 |
15 | it('renders correctly', () => {
16 | renderer.create( );
17 | });
18 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "org.jetbrains.kotlin.android"
3 | apply plugin: "com.facebook.react"
4 |
5 | /**
6 | * This is the configuration block to customize your React Native Android app.
7 | * By default you don't need to apply any configuration, just uncomment the lines you need.
8 | */
9 | react {
10 | /* Folders */
11 | // The root of your project, i.e. where "package.json" lives. Default is '..'
12 | // root = file("../")
13 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native
14 | // reactNativeDir = file("../node_modules/react-native")
15 | // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
16 | // codegenDir = file("../node_modules/@react-native/codegen")
17 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
18 | // cliFile = file("../node_modules/react-native/cli.js")
19 |
20 | /* Variants */
21 | // The list of variants to that are debuggable. For those we're going to
22 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24 | // debuggableVariants = ["liteDebug", "prodDebug"]
25 |
26 | /* Bundling */
27 | // A list containing the node command and its flags. Default is just 'node'.
28 | // nodeExecutableAndArgs = ["node"]
29 | //
30 | // The command to run when bundling. By default is 'bundle'
31 | // bundleCommand = "ram-bundle"
32 | //
33 | // The path to the CLI configuration file. Default is empty.
34 | // bundleConfig = file(../rn-cli.config.js)
35 | //
36 | // The name of the generated asset file containing your JS bundle
37 | // bundleAssetName = "MyApplication.android.bundle"
38 | //
39 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40 | // entryFile = file("../js/MyApplication.android.js")
41 | //
42 | // A list of extra flags to pass to the 'bundle' commands.
43 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44 | // extraPackagerArgs = []
45 |
46 | /* Hermes Commands */
47 | // The hermes compiler command to run. By default it is 'hermesc'
48 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49 | //
50 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51 | // hermesFlags = ["-O", "-output-source-map"]
52 | }
53 |
54 | /**
55 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
56 | */
57 | def enableProguardInReleaseBuilds = false
58 |
59 | /**
60 | * The preferred build flavor of JavaScriptCore (JSC)
61 | *
62 | * For example, to use the international variant, you can use:
63 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
64 | *
65 | * The international variant includes ICU i18n library and necessary data
66 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
67 | * give correct results when using with locales other than en-US. Note that
68 | * this variant is about 6MiB larger per architecture than default.
69 | */
70 | def jscFlavor = 'org.webkit:android-jsc:+'
71 |
72 | android {
73 | ndkVersion rootProject.ext.ndkVersion
74 | buildToolsVersion rootProject.ext.buildToolsVersion
75 | compileSdk rootProject.ext.compileSdkVersion
76 |
77 | namespace "com.demoapp"
78 | defaultConfig {
79 | applicationId "com.demoapp"
80 | minSdkVersion rootProject.ext.minSdkVersion
81 | targetSdkVersion rootProject.ext.targetSdkVersion
82 | versionCode 1
83 | versionName "1.0"
84 | }
85 | signingConfigs {
86 | debug {
87 | storeFile file('debug.keystore')
88 | storePassword 'android'
89 | keyAlias 'androiddebugkey'
90 | keyPassword 'android'
91 | }
92 | }
93 | buildTypes {
94 | debug {
95 | signingConfig signingConfigs.debug
96 | }
97 | release {
98 | // Caution! In production, you need to generate your own keystore file.
99 | // see https://reactnative.dev/docs/signed-apk-android.
100 | signingConfig signingConfigs.debug
101 | minifyEnabled enableProguardInReleaseBuilds
102 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
103 | }
104 | }
105 | }
106 |
107 | dependencies {
108 | // The version of react-native is set by the React Native Gradle Plugin
109 | implementation("com.facebook.react:react-android")
110 |
111 | if (hermesEnabled.toBoolean()) {
112 | implementation("com.facebook.react:hermes-android")
113 | } else {
114 | implementation jscFlavor
115 | }
116 | }
117 |
118 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
119 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/demoapp/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/java/com/demoapp/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.demoapp
2 |
3 | import com.facebook.react.ReactActivity
4 | import com.facebook.react.ReactActivityDelegate
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate
7 |
8 | class MainActivity : ReactActivity() {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | override fun getMainComponentName(): String = "demoapp"
15 |
16 | /**
17 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19 | */
20 | override fun createReactActivityDelegate(): ReactActivityDelegate =
21 | DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22 | }
23 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/java/com/demoapp/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.demoapp
2 |
3 | import android.app.Application
4 | import com.facebook.react.PackageList
5 | import com.facebook.react.ReactApplication
6 | import com.facebook.react.ReactHost
7 | import com.facebook.react.ReactNativeHost
8 | import com.facebook.react.ReactPackage
9 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11 | import com.facebook.react.defaults.DefaultReactNativeHost
12 | import com.facebook.soloader.SoLoader
13 |
14 | class MainApplication : Application(), ReactApplication {
15 |
16 | override val reactNativeHost: ReactNativeHost =
17 | object : DefaultReactNativeHost(this) {
18 | override fun getPackages(): List =
19 | PackageList(this).packages.apply {
20 | // Packages that cannot be autolinked yet can be added manually here, for example:
21 | // add(MyReactNativePackage())
22 | }
23 |
24 | override fun getJSMainModuleName(): String = "index"
25 |
26 | override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
27 |
28 | override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
29 | override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
30 | }
31 |
32 | override val reactHost: ReactHost
33 | get() = getDefaultReactHost(applicationContext, reactNativeHost)
34 |
35 | override fun onCreate() {
36 | super.onCreate()
37 | SoLoader.init(this, false)
38 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
39 | // If you opted-in for the New Architecture, we load the native entry point for this app.
40 | load()
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
22 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | demoapp
3 |
4 |
--------------------------------------------------------------------------------
/example/demoapp/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/demoapp/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | buildToolsVersion = "34.0.0"
4 | minSdkVersion = 23
5 | compileSdkVersion = 34
6 | targetSdkVersion = 34
7 | ndkVersion = "26.1.10909125"
8 | kotlinVersion = "1.9.22"
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle")
16 | classpath("com.facebook.react:react-native-gradle-plugin")
17 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18 | }
19 | }
20 |
21 | apply plugin: "com.facebook.react.rootproject"
22 |
--------------------------------------------------------------------------------
/example/demoapp/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 | # Automatically convert third-party libraries to use AndroidX
25 | android.enableJetifier=true
26 |
27 | # Use this property to specify which architecture you want to build.
28 | # You can also override it from the CLI using
29 | # ./gradlew -PreactNativeArchitectures=x86_64
30 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
31 |
32 | # Use this property to enable support to the new architecture.
33 | # This will allow you to use TurboModules and the Fabric render in
34 | # your application. You should enable this flag either if you want
35 | # to write custom TurboModules/Fabric components OR use libraries that
36 | # are providing them.
37 | newArchEnabled=false
38 |
39 | # Use this property to enable or disable the Hermes JS engine.
40 | # If set to false, you will be using JSC instead.
41 | hermesEnabled=true
42 |
--------------------------------------------------------------------------------
/example/demoapp/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/demoapp/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/example/demoapp/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88 |
89 | # Use the maximum available, or set MAX_FD != -1 to use that value.
90 | MAX_FD=maximum
91 |
92 | warn () {
93 | echo "$*"
94 | } >&2
95 |
96 | die () {
97 | echo
98 | echo "$*"
99 | echo
100 | exit 1
101 | } >&2
102 |
103 | # OS specific support (must be 'true' or 'false').
104 | cygwin=false
105 | msys=false
106 | darwin=false
107 | nonstop=false
108 | case "$( uname )" in #(
109 | CYGWIN* ) cygwin=true ;; #(
110 | Darwin* ) darwin=true ;; #(
111 | MSYS* | MINGW* ) msys=true ;; #(
112 | NONSTOP* ) nonstop=true ;;
113 | esac
114 |
115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116 |
117 |
118 | # Determine the Java command to use to start the JVM.
119 | if [ -n "$JAVA_HOME" ] ; then
120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
121 | # IBM's JDK on AIX uses strange locations for the executables
122 | JAVACMD=$JAVA_HOME/jre/sh/java
123 | else
124 | JAVACMD=$JAVA_HOME/bin/java
125 | fi
126 | if [ ! -x "$JAVACMD" ] ; then
127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
128 |
129 | Please set the JAVA_HOME variable in your environment to match the
130 | location of your Java installation."
131 | fi
132 | else
133 | JAVACMD=java
134 | if ! command -v java >/dev/null 2>&1
135 | then
136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 | fi
142 |
143 | # Increase the maximum file descriptors if we can.
144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145 | case $MAX_FD in #(
146 | max*)
147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148 | # shellcheck disable=SC2039,SC3045
149 | MAX_FD=$( ulimit -H -n ) ||
150 | warn "Could not query maximum file descriptor limit"
151 | esac
152 | case $MAX_FD in #(
153 | '' | soft) :;; #(
154 | *)
155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156 | # shellcheck disable=SC2039,SC3045
157 | ulimit -n "$MAX_FD" ||
158 | warn "Could not set maximum file descriptor limit to $MAX_FD"
159 | esac
160 | fi
161 |
162 | # Collect all arguments for the java command, stacking in reverse order:
163 | # * args from the command line
164 | # * the main class name
165 | # * -classpath
166 | # * -D...appname settings
167 | # * --module-path (only if needed)
168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
169 |
170 | # For Cygwin or MSYS, switch paths to Windows format before running java
171 | if "$cygwin" || "$msys" ; then
172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command:
206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207 | # and any embedded shellness will be escaped.
208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209 | # treated as '${Hostname}' itself on the command line.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -classpath "$CLASSPATH" \
214 | org.gradle.wrapper.GradleWrapperMain \
215 | "$@"
216 |
217 | # Stop when "xargs" is not available.
218 | if ! command -v xargs >/dev/null 2>&1
219 | then
220 | die "xargs is not available"
221 | fi
222 |
223 | # Use "xargs" to parse quoted args.
224 | #
225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
226 | #
227 | # In Bash we could simply go:
228 | #
229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
230 | # set -- "${ARGS[@]}" "$@"
231 | #
232 | # but POSIX shell has neither arrays nor command substitution, so instead we
233 | # post-process each arg (as a line of input to sed) to backslash-escape any
234 | # character that might be a shell metacharacter, then use eval to reverse
235 | # that process (while maintaining the separation between arguments), and wrap
236 | # the whole thing up as a single "set" statement.
237 | #
238 | # This will of course break if any of these variables contains a newline or
239 | # an unmatched quote.
240 | #
241 |
242 | eval "set -- $(
243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
244 | xargs -n1 |
245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246 | tr '\n' ' '
247 | )" '"$@"'
248 |
249 | exec "$JAVACMD" "$@"
250 |
--------------------------------------------------------------------------------
/example/demoapp/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/example/demoapp/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'demoapp'
2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3 | include ':app'
4 | includeBuild('../node_modules/@react-native/gradle-plugin')
5 |
--------------------------------------------------------------------------------
/example/demoapp/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demoapp",
3 | "displayName": "demoapp"
4 | }
5 |
--------------------------------------------------------------------------------
/example/demoapp/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:@react-native/babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/example/demoapp/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | // import App from './App';
6 | import {name as appName} from './app.json';
7 | import {
8 | AppRegistry,
9 | DeviceEventEmitter} from 'react-native';
10 | import { NavigationContainer } from '@react-navigation/native';
11 | import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
12 | import { enableScreens } from 'react-native-screens';
13 | import Actions from './Actions';
14 | import Settings from './Settings';
15 |
16 | const Tab = createBottomTabNavigator();
17 |
18 | const App = () => {
19 | return (
20 |
21 |
22 |
26 |
27 |
28 |
29 | );
30 | };
31 |
32 | AppRegistry.registerComponent(appName, () => App);
33 |
34 | // this event is fired when the push is received in the app
35 | DeviceEventEmitter.addListener('pushReceived', (e) => {
36 | console.warn("pushReceived: " + JSON.stringify(e));
37 | // shows a push is received. Implement passive reaction to a push, such as UI update or data download.
38 | });
39 |
40 | // this event is fired when user clicks on notification
41 | DeviceEventEmitter.addListener('pushOpened', (e) => {
42 | console.warn("pushOpened: " + JSON.stringify(e));
43 | // shows a user tapped the notification. Implement user interaction, such as showing push details
44 | });
45 |
46 | enableScreens();
--------------------------------------------------------------------------------
/example/demoapp/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/example/demoapp/ios/NotificationService/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PW_APP_GROUPS_NAME
6 |
7 | NSExtension
8 |
9 | NSExtensionPointIdentifier
10 | com.apple.usernotifications.service
11 | NSExtensionPrincipalClass
12 | $(PRODUCT_MODULE_NAME).NotificationService
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/example/demoapp/ios/NotificationService/NotificationService.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.application-groups
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/demoapp/ios/NotificationService/NotificationService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NotificationService.swift
3 | // NotificationService
4 | //
5 | // Created by Andrew Kis on 15.5.24..
6 | //
7 |
8 | import UserNotifications
9 | import PushwooshFramework
10 |
11 | /**
12 | Setting up Badges for Flutter
13 | docs: https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin
14 |
15 | 1. Add App Groups capability to both Runner and NotificationService targets and add a new group with the same name for both targets
16 | 2. Add PW_APP_GROUPS_NAME info.plist flag to both Main Target and NotificationService targets with the group name as its string value
17 | 7. Add code
18 | */
19 |
20 | class NotificationService: UNNotificationServiceExtension {
21 |
22 | var contentHandler: ((UNNotificationContent) -> Void)?
23 | var bestAttemptContent: UNMutableNotificationContent?
24 |
25 | override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
26 |
27 | PWNotificationExtensionManager.shared().handle(request, contentHandler: contentHandler)
28 | }
29 |
30 | override func serviceExtensionTimeWillExpire() {
31 | // Called just before the extension will be terminated by the system.
32 | // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
33 | if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
34 | contentHandler(bestAttemptContent)
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/example/demoapp/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Resolve react_native_pods.rb with node to allow for hoisting
2 | require Pod::Executable.execute_command('node', ['-p',
3 | 'require.resolve(
4 | "react-native/scripts/react_native_pods.rb",
5 | {paths: [process.argv[1]]},
6 | )', __dir__]).strip
7 |
8 | platform :ios, min_ios_version_supported
9 | prepare_react_native_project!
10 |
11 | linkage = ENV['USE_FRAMEWORKS']
12 | if linkage != nil
13 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
14 | use_frameworks! :linkage => linkage.to_sym
15 | end
16 |
17 | target 'demoapp' do
18 | config = use_native_modules!
19 |
20 | use_react_native!(
21 | :path => config[:reactNativePath],
22 | # An absolute path to your application root.
23 | :app_path => "#{Pod::Config.instance.installation_root}/.."
24 | )
25 |
26 | target 'demoappTests' do
27 | inherit! :complete
28 | # Pods for testing
29 | end
30 |
31 | post_install do |installer|
32 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
33 | react_native_post_install(
34 | installer,
35 | config[:reactNativePath],
36 | :mac_catalyst_enabled => false,
37 | # :ccache_enabled => true
38 | )
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp.xcodeproj/xcshareddata/xcschemes/demoapp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : RCTAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 |
5 | @implementation AppDelegate
6 |
7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
8 | {
9 | self.moduleName = @"demoapp";
10 | // You can add your custom initial props in the dictionary below.
11 | // They will be passed down to the ViewController used by React Native.
12 | self.initialProps = @{};
13 |
14 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
15 | }
16 |
17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18 | {
19 | return [self bundleURL];
20 | }
21 |
22 | - (NSURL *)bundleURL
23 | {
24 | #if DEBUG
25 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
26 | #else
27 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
28 | #endif
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PW_APP_GROUPS_NAME
6 |
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleDisplayName
10 | demoapp
11 | CFBundleExecutable
12 | $(EXECUTABLE_NAME)
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | $(PRODUCT_NAME)
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | $(MARKETING_VERSION)
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | $(CURRENT_PROJECT_VERSION)
27 | LSRequiresIPhoneOS
28 |
29 | NSAppTransportSecurity
30 |
31 | NSAllowsArbitraryLoads
32 |
33 | NSAllowsLocalNetworking
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | UIBackgroundModes
39 |
40 | remote-notification
41 |
42 | UILaunchStoryboardName
43 | LaunchScreen
44 | UIRequiredDeviceCapabilities
45 |
46 | arm64
47 |
48 | UISupportedInterfaceOrientations
49 |
50 | UIInterfaceOrientationPortrait
51 | UIInterfaceOrientationLandscapeLeft
52 | UIInterfaceOrientationLandscapeRight
53 |
54 | UIViewControllerBasedStatusBarAppearance
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/demoapp.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 | com.apple.security.application-groups
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoapp/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | @autoreleasepool {
8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoappTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/demoapp/ios/demoappTests/demoappTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface demoappTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation demoappTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(
38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
39 | if (level >= RCTLogLevelError) {
40 | redboxError = message;
41 | }
42 | });
43 | #endif
44 |
45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
48 |
49 | foundElement = [self findSubviewInView:vc.view
50 | matching:^BOOL(UIView *view) {
51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
52 | return YES;
53 | }
54 | return NO;
55 | }];
56 | }
57 |
58 | #ifdef DEBUG
59 | RCTSetLogFunction(RCTDefaultLogFunction);
60 | #endif
61 |
62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/example/demoapp/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: 'react-native',
3 | };
4 |
--------------------------------------------------------------------------------
/example/demoapp/logos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/example/demoapp/logos.png
--------------------------------------------------------------------------------
/example/demoapp/metro.config.js:
--------------------------------------------------------------------------------
1 | const { getDefaultConfig } = require('@react-native/metro-config');
2 | const path = require('path');
3 |
4 | const projectRoot = __dirname;
5 | const packagePath = path.resolve(projectRoot, '../../');
6 |
7 | const config = getDefaultConfig(projectRoot);
8 |
9 | config.resolver = {
10 | ...config.resolver,
11 | nodeModulesPaths: [path.resolve(projectRoot, 'node_modules')],
12 | extraNodeModules: {
13 | '@babel/runtime': path.resolve(projectRoot, 'node_modules/@babel/runtime'),
14 | },
15 | };
16 |
17 | config.watchFolders = [packagePath];
18 |
19 | module.exports = config;
20 |
21 |
--------------------------------------------------------------------------------
/example/demoapp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demoapp",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "lint": "eslint .",
9 | "start": "react-native start",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "@expo/vector-icons": "^14.0.2",
14 | "@react-navigation/bottom-tabs": "^6.5.20",
15 | "pushwoosh-react-native-plugin": "file:../../",
16 | "react": "18.2.0",
17 | "react-native": "0.74.1",
18 | "react-native-safe-area-context": "^4.10.1",
19 | "react-native-screens": "^3.31.1",
20 | "react-native-vector-icons": "^10.1.0"
21 | },
22 | "devDependencies": {
23 | "@babel/core": "^7.20.0",
24 | "@babel/preset-env": "^7.20.0",
25 | "@babel/runtime": "^7.26.7",
26 | "@react-native/babel-preset": "0.74.83",
27 | "@react-native/eslint-config": "0.74.83",
28 | "@react-native/metro-config": "0.74.83",
29 | "@react-native/typescript-config": "0.74.83",
30 | "@types/react": "^18.2.6",
31 | "@types/react-test-renderer": "^18.0.0",
32 | "babel-jest": "^29.6.3",
33 | "eslint": "^8.19.0",
34 | "jest": "^29.6.3",
35 | "prettier": "2.8.8",
36 | "react-test-renderer": "18.2.0",
37 | "typescript": "5.0.4"
38 | },
39 | "engines": {
40 | "node": ">=18"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/example/demoapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@react-native/typescript-config/tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'pushwoosh-react-native-plugin' {
2 | interface PushwooshConfig {
3 | pw_appid: string;
4 | project_number: string;
5 | pw_notification_handling?: string;
6 | }
7 | type LocalNotification = {
8 | msg: string;
9 | seconds: number;
10 | userData?: Object;
11 | }
12 |
13 | type PushwooshTags = Record
14 |
15 | type InboxNotification = {
16 | code: string;
17 | title?: string;
18 | message?: string;
19 | imageUrl?: string;
20 | sendDate?: string;
21 | type?: number;
22 | bannerUrl?: string;
23 | customData?: Object;
24 | isRead?: boolean;
25 | actionParams?: Object;
26 | isActionPerformed?: boolean;
27 | }
28 |
29 | interface Pushwoosh {
30 | //general interaction with Pushwoosh
31 | init(config: PushwooshConfig, success?: () => void, fail?: () => void): void;
32 | createLocalNotification(notification: LocalNotification): void;
33 | clearLocalNotification(): void;
34 | clearNotificationCenter(): void;
35 | register(success?: (token: string) => void, fail?: (error: Error) => void): void;
36 | unregister(success?: (token: string) => void, fail?: (error: Error) => void): void;
37 | onPushOpen(callback: () => void, fail?: ()=> void): void;
38 | setTags(
39 | tags: PushwooshTags,
40 | success?: () => void,
41 | fail?: (error: Error) => void
42 | ): void;
43 | getTags(success: (tags: PushwooshTags) => void, fail?: (error: Error) => void): void;
44 | setShowPushnotificationAlert(showAlert: boolean): void;
45 | getShowPushnotificationAlert(callback: (willShow: boolean) => void): void;
46 | getPushToken(success?: (token: string) => void): void;
47 | getHwid(success: (hwid: string) => void): void;
48 | getUserId(success: (userId: string) => void): void;
49 | setUserId(userId: string, success?: ()=> void, fail?: (error: Error) => void): void;
50 | postEvent(event: string, attributes?: Record): void;
51 | enableHuaweiPushNotifications(): void;
52 |
53 | //email methods
54 | setUserEmails(userId: string, emails: (string | string[]), success?: () => void, fail?: (error: Error) => void): void;
55 | setEmails(emails: (string | string[]), success?: () => void, fail?: (error: Error) => void): void;
56 | //badge methods
57 | setApplicationIconBadgeNumber(badgeNumber: number): void;
58 | getApplicationIconBadgeNumber(callback: (badge: number) => void): void;
59 | addToApplicationIconBadgeNumber(badgeNumber: number): void;
60 |
61 | //Notification appearance
62 | setMultiNotificationMode(on: boolean): void;
63 | setLightScreenOnNotification(on: boolean): void;
64 | setEnableLED(on: boolean): void;
65 | setColorLED(color: number): void;
66 | setSoundType(type: number): void;
67 | setVibrateType(type: number): void;
68 | setNotificationIconBackgroundColor(color: string): void;
69 | setLanguage(language: string): void;
70 |
71 | //Inbox API
72 | presentInboxUI(style?: Object): void;
73 | messagesWithNoActionPerformedCount(callback: (result: number) => void): void;
74 | unreadMessagesCount(callback: (result: number) => void): void;
75 | messagesCount(callback: (result: number) => void): void;
76 | loadMessages(success: (notifications: InboxNotification[]) => void, fail?: (error: Error) => void): void;
77 | readMessage(id: string): void;
78 | readMessages(ids: string[]): void;
79 | deleteMessage(id: string): void;
80 | deleteMessages(ids: string[]): void;
81 | performAction(id: string): void;
82 |
83 | //GDPR methods
84 | showGDPRConsentUI(): void;
85 | showGDPRDeletionUI(): void;
86 | isDeviceDataRemoved(success: (isRemoved: boolean) => void): void;
87 | isCommunicationEnabled(success: (isEnabled: boolean)=> void): void;
88 | isAvailableGDPR(success: (isAvailable: boolean) => void): void;
89 | setCommunicationEnabled(enabled: boolean, success?: () => void, fail?: (error: Error) => void): void;
90 | removeAllDeviceData(success?: () => void, fail?: (error: Error) => void): void;
91 | }
92 |
93 | const Pushwoosh: Pushwoosh;
94 | export = Pushwoosh;
95 | }
96 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import { NativeModules } from 'react-native';
4 |
5 | const PushwooshModule = NativeModules.Pushwoosh;
6 |
7 | //Class: PushNotification
8 | //Use `PushNotification` to register device for push notifications on Pushwoosh and customize notification appearance.
9 | //
10 | //Example:
11 | //(start code)
12 | //DeviceEventEmitter.addListener('pushOpened', (e: Event) => {
13 | // console.warn("pushOpened: " + JSON.stringify(e));
14 | // alert(JSON.stringify(e));
15 | //});
16 | //
17 | //const Pushwoosh = require('pushwoosh-react-native-plugin');
18 | //
19 | //Pushwoosh.init({ "pw_appid" : "XXXX-XXXX", "project_number" : "XXXXXXXXXXXXX", "reverse_proxy_url" : "your_url_proxy" });
20 | //
21 | //Pushwoosh.register(
22 | // (token) => {
23 | // console.warn("Registered for pushes: " + token);
24 | // },
25 | // (error) => {
26 | // console.warn("Failed to register: " + error);
27 | // }
28 | //);
29 | //(end)
30 | class PushNotification {
31 |
32 | //Function: init
33 | //Call this first thing with your Pushwoosh App ID (pw_appid parameter) and Google Project ID for Android (projectid parameter)
34 | //
35 | //Example:
36 | //(start code)
37 | // //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
38 | // Pushwoosh.init({ projectid: "XXXXXXXXXXXXXXX", pw_appid : "XXXXX-XXXXX" });
39 | //(end)
40 | init(config: Object, success: ?Function, fail: ?Function) {
41 | if (!success) {
42 | success = function() {};
43 | }
44 | if (!fail) {
45 | fail = function(error) {};
46 | }
47 | PushwooshModule.init(config, success, fail);
48 | }
49 |
50 | //Function: createLocalNotification
51 | //Creates a local notification with a specified message, delay and custom data
52 | //
53 | //Example:
54 | //(start code)
55 | // //creates a local notification with "message" content, 5 seconds delay and passes {"somedata":"optional"} object in payload
56 | // Pushwoosh.createLocalNotification({msg:"message", seconds:5, userData:{"somedata":"optional"}});
57 | //(end)
58 |
59 | createLocalNotification(data: Object){
60 | PushwooshModule.createLocalNotification(data);
61 | }
62 |
63 | //Function: clearLocalNotification
64 | //Clears all existing and cancels all pending local notifications
65 | //
66 | //Example:
67 | //(start code)
68 | // Pushwoosh.clearLocalNotification();
69 | //(end)
70 |
71 | clearLocalNotification(){
72 | PushwooshModule.clearLocalNotification();
73 | }
74 |
75 | //Function: clearNotificationCenter
76 | //Clears all existing and cancels all pending notifications
77 | //
78 | //Example:
79 | //(start code)
80 | // Pushwoosh.clearNotificationCenter();
81 | //(end)
82 | clearNotificationCenter(){
83 | PushwooshModule.clearNotificationCenter();
84 | }
85 |
86 | //Function: register
87 | //Call this to register for push notifications and retreive a push Token
88 | //
89 | //Example:
90 | //(start code)
91 | // Pushwoosh.registerDevice(
92 | // function(token)
93 | // {
94 | // alert(token);
95 | // },
96 | // function(status)
97 | // {
98 | // alert("failed to register: " + status);
99 | // }
100 | // );
101 | //(end)
102 | register(success: ?Function, fail: ?Function) {
103 | if (!success) {
104 | success = function(token) {};
105 | }
106 | if (!fail) {
107 | fail = function(error) {};
108 | }
109 | PushwooshModule.register(success, fail);
110 | }
111 |
112 | //Function: unregister
113 | //Unregisters device from push notifications
114 | unregister(success: ?Function, fail: ?Function) {
115 | if (!success) {
116 | success = function(token) {};
117 | }
118 | if (!fail) {
119 | fail = function(error) {};
120 | }
121 | PushwooshModule.unregister(success, fail);
122 | }
123 |
124 | //Function: onPushOpen
125 | //Deprecated - use DeviceEventEmitter.addListener('pushOpened', callback) instead
126 | onPushOpen(callback: Function) {
127 | PushwooshModule.onPushOpen(callback);
128 | }
129 |
130 | //Function: setUserEmails
131 | //Register emails list associated to the current user.
132 | //
133 | //Example:
134 | //(start code)
135 | // Pushwoosh.setUserEmails("someUser", ["example@mail.some"],
136 | // function(status) {
137 | // console.warn('setUserEmails success');
138 | // },
139 | // function(status) {
140 | // console.warn('setUserEmails failed');
141 | // }
142 | // );
143 | //
144 | setUserEmails(userId: string, emails: Object, success: ?Function, fail: ?Function) {
145 | if (!success) {
146 | success = function() {};
147 | }
148 | if (!fail) {
149 | fail = function(error) {};
150 | }
151 | PushwooshModule.setUserEmails(userId, emails, success, fail);
152 | }
153 |
154 |
155 | //Function: setEmails
156 | //Register emails list associated to the current user.
157 | //
158 | //Example:
159 | //(start code)
160 | // Pushwoosh.setEmails(["example@mail.some"],
161 | // function(status) {
162 | // console.warn('setEmails success');
163 | // },
164 | // function(status) {
165 | // console.warn('setEmails failed');
166 | // }
167 | // );
168 | //
169 | setEmails(emails: Object, success: ?Function, fail: ?Function) {
170 | if (!success) {
171 | success = function() {};
172 | }
173 | if (!fail) {
174 | fail = function(error) {};
175 | }
176 | PushwooshModule.setEmails(emails, success, fail);
177 | }
178 |
179 | //Function: setTags
180 | //Call this to set tags for the device
181 | //
182 | //Example:
183 | //sets the following tags: "deviceName" with value "hello" and "deviceId" with value 10
184 | //(start code)
185 | // Pushwoosh.setTags({deviceName:"hello", deviceId:10},
186 | // function(status) {
187 | // console.warn('setTags success');
188 | // },
189 | // function(status) {
190 | // console.warn('setTags failed');
191 | // }
192 | // );
193 | //
194 | // //settings list tags "MyTag" with values (array) "hello", "world"
195 | // pushNotification.setTags({"MyTag":["hello", "world"]});
196 | //(end)
197 | setTags(tags: Object, success: ?Function, fail: ?Function) {
198 | if (!success) {
199 | success = function() {};
200 | }
201 | if (!fail) {
202 | fail = function(error) {};
203 | }
204 | PushwooshModule.setTags(tags, success, fail);
205 | }
206 |
207 | //Function: getTags
208 | //Call this to get tags for the device
209 | //
210 | //Example:
211 | //(start code)
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 | //(end)
223 | getTags(success: Function, fail: ?Function) {
224 | if (!fail) {
225 | fail = function(error) {};
226 | }
227 | PushwooshModule.getTags(success, fail);
228 | }
229 |
230 | //Function: setShowPushnotificationAlert
231 | //Set push notifications alert when push notification is received while the app is running, default is `true`
232 | //
233 | //Example:
234 | //(start code)
235 | // Pushwoosh.setShowPushnotificationAlert(false);
236 | //(end)
237 | setShowPushnotificationAlert(showPushnotificationAlert: boolean) {
238 | PushwooshModule.setShowPushnotificationAlert(showPushnotificationAlert);
239 | }
240 |
241 | //Function: getShowPushnotificationAlert
242 | //Show push notifications alert when push notification is received while the app is running, default is `true`
243 | //
244 | //Example:
245 | //(start code)
246 | // Pushwoosh.getShowPushnotificationAlert((showPushnotificationAlert) => {
247 | // console.warn("showPushnotificationAlert = " + showPushnotificationAlert);
248 | // });
249 | //(end)
250 | getShowPushnotificationAlert(callback: Function) {
251 | PushwooshModule.getShowPushnotificationAlert(callback);
252 | }
253 |
254 | //Function: getPushToken
255 | //Call this to get push token if it is available. Note the token also comes in registerDevice function callback.
256 | //
257 | //Example:
258 | //(start code)
259 | // Pushwoosh.getPushToken(
260 | // function(token)
261 | // {
262 | // console.warn('push token: ' + token);
263 | // }
264 | // );
265 | //(end)
266 | getPushToken(success: Function) {
267 | PushwooshModule.getPushToken(success);
268 | }
269 |
270 | //Function: getHwid
271 | //Call this to get Pushwoosh HWID used for communications with Pushwoosh API
272 | //
273 | //Example:
274 | //(start code)
275 | // Pushwoosh.getHwid(
276 | // function(token) {
277 | // console.warn('Pushwoosh HWID: ' + token);
278 | // }
279 | // );
280 | //(end)
281 | getHwid(success: Function) {
282 | PushwooshModule.getHwid(success);
283 | }
284 |
285 | //Function: getUserId
286 | //Call this to get Pushwoosh User ID used for communications with Pushwoosh API
287 | //
288 | //Example:
289 | //(start code)
290 | // Pushwoosh.getUserId();
291 | //(end)
292 | getUserId(success: Function) {
293 | PushwooshModule.getUserId(success);
294 | }
295 |
296 | //Function: setUserId
297 | //[android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
298 | //This allows data and events to be matched across multiple user devices.
299 | //
300 | //Parameters:
301 | // "userId" - user string identifier
302 | //
303 | setUserId(userId: string) {
304 | PushwooshModule.setUserId(userId);
305 | }
306 |
307 | //Function: setUserId: completion:
308 | //[android, ios] Set User indetifier. This could be Facebook ID, username or email, or any other user ID.
309 | //This allows data and events to be matched across multiple user devices.
310 | //If setUserId succeeds competion is called with nil argument. If setUserId fails completion is called with error.
311 | //Parameters:
312 | // "userId" - user string identifier
313 | setUserId(userId: string, success: ?Function, fail: ?Function) {
314 | if (!success) {
315 | success = function() {};
316 | }
317 | if (!fail) {
318 | fail = function(error) {};
319 | }
320 | PushwooshModule.setUserId(userId, success, fail);
321 | }
322 |
323 | //Function: postEvent
324 | //[android, ios] Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel.
325 | //
326 | //Parameters:
327 | // "event" - event to trigger
328 | // "attributes" - object with additional event attributes
329 | //
330 | // Example:
331 | //(start code)
332 | // Pushwoosh.setUserId("XXXXXX");
333 | // Pushwoosh.postEvent("buttonPressed", { "buttonNumber" : 4, "buttonLabel" : "banner" });
334 | //(end)
335 | postEvent(event: string, attributes: ?Object) {
336 | if (!attributes) {
337 | attributes = {};
338 | }
339 | PushwooshModule.postEvent(event, attributes);
340 | }
341 |
342 | //Function: setApplicationIconBadgeNumber
343 | //[android, ios, wp8, windows] Set the application icon badge number
344 | //
345 | //Parameters:
346 | // "badgeNumber" - icon badge number
347 | //
348 | setApplicationIconBadgeNumber(badgeNumber: number) {
349 | PushwooshModule.setApplicationIconBadgeNumber(badgeNumber);
350 | }
351 |
352 | //Function: getApplicationIconBadgeNumber
353 | //[android, ios] Returns the application icon badge number
354 | //
355 | //Parameters:
356 | // "callback" - success callback
357 | //
358 | //Example:
359 | //(start code)
360 | // Pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );
361 | //(end)
362 | getApplicationIconBadgeNumber(callback: Function) {
363 | PushwooshModule.getApplicationIconBadgeNumber(callback);
364 | }
365 |
366 | //Function: addToApplicationIconBadgeNumber
367 | //[android, ios] Adds value to the application icon badge
368 | //
369 | //Parameters:
370 | // "badgeNumber" - incremental icon badge number
371 | //
372 | //Example:
373 | //(start code)
374 | // Pushwoosh.addToApplicationIconBadgeNumber(5);
375 | // Pushwoosh.addToApplicationIconBadgeNumber(-5);
376 | //(end)
377 | addToApplicationIconBadgeNumber(badgeNumber: number) {
378 | PushwooshModule.addToApplicationIconBadgeNumber(badgeNumber);
379 | }
380 |
381 | //Function: setMultiNotificationMode
382 | //[android] Allows multiple notifications to be displayed in the Android Notification Center
383 | setMultiNotificationMode(on: boolean) {
384 | PushwooshModule.setMultiNotificationMode(on);
385 | }
386 |
387 | //Function: setLightScreenOnNotification
388 | //[android] Turns the screen on if notification arrives
389 | //
390 | //Parameters:
391 | // "on" - enable/disable screen unlock (is disabled by default)
392 | //
393 | setLightScreenOnNotification(on: boolean) {
394 | PushwooshModule.setLightScreenOnNotification(on);
395 | }
396 |
397 | //Function: setEnableLED
398 | //[android] Enables led blinking when notification arrives and display is off
399 | //
400 | //Parameters:
401 | // "on" - enable/disable led blink (is disabled by default)
402 | //
403 | setEnableLED(on: boolean) {
404 | PushwooshModule.setEnableLED(on);
405 | }
406 |
407 | //Function: setEnableLED
408 | //[android] Set led color. Use with
409 | //
410 | //Parameters:
411 | // "color" - led color in ARGB integer format
412 | //
413 | setColorLED(color: number) {
414 | PushwooshModule.setColorLED(color);
415 | }
416 |
417 | //Function: setSoundType
418 | //[android] Sets default sound to play when push notification arrive.
419 | //
420 | //Parameters:
421 | // "type" - Sound type (0 - default, 1 - no sound, 2 - always)
422 | //
423 | setSoundType(type: number) {
424 | PushwooshModule.setSoundType(type);
425 | }
426 |
427 | //Function: setVibrateType
428 | //[android] Sets default vibration mode when push notification arrive.
429 | //
430 | //Parameters:
431 | // "type" - Vibration type (0 - default, 1 - no vibration, 2 - always)
432 | //
433 | setVibrateType(type: number) {
434 | PushwooshModule.setVibrateType(type);
435 | }
436 |
437 | //Function: presentInboxUI
438 | //[android, ios] Opens Inbox screen.
439 | //
440 | // Supported style keys:
441 | //
442 | // Customizes the date formatting
443 | // "dateFormat"
444 | //
445 | // The default icon in the cell next to the message; if not specified, the app icon is used
446 | // "defaultImageIcon"
447 | //
448 | // The appearance of the unread messages mark (iOS only)
449 | // "unreadImage"
450 | //
451 | // The image which is displayed if an error occurs and the list of inbox messages is empty
452 | // "listErrorImage"
453 | //
454 | // The image which is displayed if the list of inbox messages is empty
455 | // "listEmptyImage"
456 | //
457 | // The error text which is displayed when an error occurs; cannot be localized
458 | // "listErrorMessage"
459 | //
460 | // The text which is displayed if the list of inbox messages is empty; cannot be localized
461 | // "listEmptyMessage"
462 | //
463 | // The default text color (iOS only)
464 | // "defaultTextColor"
465 | //
466 | // The accent color
467 | // "accentColor"
468 | //
469 | // The default background color
470 | // "backgroundColor"
471 | //
472 | // The default selection color
473 | // "highlightColor"
474 | //
475 | // The color of message titles
476 | // "titleColor"
477 | //
478 | // The color of message titles if message was readed (Android only)
479 | // "readTitleColor"
480 | //
481 | // The color of messages descriptions
482 | // "descriptionColor"
483 | //
484 | // The color of messages descriptions if message was readed (Android only)
485 | // "readDescriptionColor"
486 | //
487 | // The color of message dates
488 | // "dateColor"
489 | //
490 | // The color of message dates if message was readed (Android only)
491 | // "readDateColor"
492 | //
493 | // The color of the separator
494 | // "dividerColor"
495 | //
496 | //Example:
497 | //(start code)
498 | // Pushwoosh.presentInboxUI({
499 | // "dateFormat" : "dd.MMMM.YYYY",
500 | // "defaultImageIcon" : Image.resolveAssetSource(require('./icon.png')),
501 | // "listErrorImage" : Image.resolveAssetSource(require('./error.png')),
502 | // "listEmptyImage" : Image.resolveAssetSource(require('./empty.png')),
503 | // "listErrorMessage" : "Error message1",
504 | // "listEmptyMessage" : "Error message2",
505 | // "accentColor" : processColor('#ff00ff'),
506 | // "highlightColor" : processColor('yellow'),
507 | // "dateColor" : processColor('blue'),
508 | // "titleColor" : processColor('#ff00ff'),
509 | // "dividerColor" : processColor('#ff00ff'),
510 | // "descriptionColor" : processColor('green'),
511 | // "backgroundColor" : processColor('rgba(255, 100, 30, 1.0)'),
512 | // "barBackgroundColor" : processColor('#ffffff'),
513 | // "barAccentColor" : processColor('#ffd700'),
514 | // "barTextColor" : processColor('#282828')
515 | // });
516 | //(end)
517 |
518 | presentInboxUI(style: ?Object) {
519 | PushwooshModule.presentInboxUI(style);
520 | }
521 |
522 | messagesWithNoActionPerformedCount(result: Function) {
523 | PushwooshModule.messagesWithNoActionPerformedCount(result);
524 | }
525 |
526 | unreadMessagesCount(result: Function) {
527 | PushwooshModule.unreadMessagesCount(result);
528 | }
529 |
530 | messagesCount(result: Function) {
531 | PushwooshModule.messagesCount(result);
532 | }
533 |
534 | loadMessages(success: Function, fail: ?Function) {
535 | if (!fail) {
536 | fail = function() {};
537 | }
538 | PushwooshModule.loadMessages(success, fail);
539 | }
540 |
541 | readMessage(id: string) {
542 | PushwooshModule.readMessage(id);
543 | }
544 |
545 | readMessages(ids: Array) {
546 | PushwooshModule.readMessages(ids);
547 | }
548 |
549 | deleteMessage(id: string) {
550 | PushwooshModule.deleteMessage(id);
551 | }
552 |
553 | deleteMessages(ids: Array) {
554 | PushwooshModule.deleteMessages(ids);
555 | }
556 |
557 | performAction(id: string) {
558 | PushwooshModule.performAction(id);
559 | }
560 |
561 | // Show inApp for change setting Enable/disable all communication with Pushwoosh
562 | showGDPRConsentUI(){
563 | PushwooshModule.showGDPRConsentUI();
564 | }
565 |
566 | // Show inApp for all device data from Pushwoosh and stops all interactions and communication permanently.
567 | showGDPRDeletionUI(){
568 | PushwooshModule.showGDPRDeletionUI();
569 | }
570 |
571 | isDeviceDataRemoved(success: Function){
572 | PushwooshModule.isDeviceDataRemoved(success);
573 | }
574 |
575 | // Return flag is enable communication with server
576 | isCommunicationEnabled(success: Function){
577 | PushwooshModule.isCommunicationEnabled(success);
578 | }
579 |
580 | // Return flag is enabled GDPR on server
581 | isAvailableGDPR(success: Function){
582 | PushwooshModule.isAvailableGDPR(success);
583 | }
584 |
585 | // Enable/disable all communication with Pushwoosh. Enabled by default.
586 | setCommunicationEnabled(enable: boolean, success: ?Function, fail: ?Function) {
587 | if (!success) {
588 | success = function() {};
589 | }
590 | if (!fail) {
591 | fail = function(error) {};
592 | }
593 | PushwooshModule.setCommunicationEnabled(enable, success, fail);
594 | }
595 |
596 | // Removes all device data from Pushwoosh and stops all interactions and communication permanently.
597 | removeAllDeviceData( success: ?Function, fail: ?Function) {
598 | if (!success) {
599 | success = function() {};
600 | }
601 | if (!fail) {
602 | fail = function(error) {};
603 | }
604 | PushwooshModule.removeAllDeviceData(success, fail);
605 | }
606 |
607 | // Set notification icon background color
608 | setNotificationIconBackgroundColor(color: string) {
609 | PushwooshModule.setNotificationIconBackgroundColor(color);
610 | }
611 |
612 | // Set custom application language. Must be a lowercase two-letter code according to ISO-639-1 standard ("en", "de", "fr", etc.).
613 | // Device language used by default.
614 | // Set to null if you want to use device language again.
615 | setLanguage(language: string) {
616 | PushwooshModule.setLanguage(language);
617 | }
618 |
619 | // Enables Huawei push messaging
620 | enableHuaweiPushNotifications() {
621 | PushwooshModule.enableHuaweiPushNotifications();
622 | }
623 | }
624 |
625 | module.exports = new PushNotification();
626 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pushwoosh-react-native-plugin",
3 | "version": "6.1.39",
4 | "description": "This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).",
5 | "main": "index.js",
6 | "types": "index.d.ts",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/Pushwoosh/pushwoosh-react-native-plugin.git"
10 | },
11 | "keywords": [
12 | "push",
13 | "notification"
14 | ],
15 | "author": "Pushwoosh",
16 | "license": "MIT",
17 | "bugs": {
18 | "url": "https://github.com/Pushwoosh/pushwoosh-react-native-plugin/issues"
19 | },
20 | "rnpm": {
21 | "android": {
22 | "sourceDir": "./src/android"
23 | },
24 | "ios": {
25 | "podspecName": "pushwoosh-react-native-plugin",
26 | "podspecPath": "./pushwoosh-react-native-plugin.podspec",
27 | "assets" : [ "./src/ios/PushwooshInboxBundle.bundle" ]
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/pushwoosh-react-native-plugin.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "pushwoosh-react-native-plugin"
3 | s.version = "6.1.39"
4 | s.summary = "React Native Pushwoosh Push Notifications module"
5 | s.requires_arc = true
6 | s.author = 'Pushwoosh'
7 | s.license = 'MIT'
8 | s.homepage = 'n/a'
9 | s.source = { :git => "https://github.com/Pushwoosh/pushwoosh-react-native-plugin.git" }
10 | s.source_files = 'src/ios/PushwooshPlugin/Pushwoosh.{h,m}', 'src/ios/PushwooshPlugin/PWEventDispatcher.{h,m}', 'src/ios/PushwooshPlugin/PWInlineInAppManager.{h,m}'
11 | s.platform = :ios, "11.0"
12 | s.xcconfig = {
13 | "HEADER_SEARCH_PATHS" => "${PODS_ROOT}/Headers/Public/React"
14 | }
15 | s.static_framework = true
16 |
17 | s.dependency 'React'
18 | s.dependency 'PushwooshXCFramework', '6.8.6'
19 | s.dependency 'PushwooshInboxUIXCFramework'
20 | end
21 |
--------------------------------------------------------------------------------
/react-native.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | dependency: {
3 | platforms: {
4 | android: {
5 | sourceDir: "./src/android"
6 | }
7 | }
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/scripts/add_inbox_ios_resources.js:
--------------------------------------------------------------------------------
1 | require('react-native/setupBabel')();
2 |
3 | const core = require('react-native/local-cli/core');
4 | const PbxFile = require('xcode/lib/pbxFile');
5 | const path = require('path');
6 | const xcode = require('xcode');
7 | const fs = require('fs');
8 | const createGroupWithMessage = require('react-native/local-cli/link/ios/createGroupWithMessage');
9 |
10 | function pwAddInboxiOSResources() {
11 | core.configPromise.then(function(config) {
12 | const iOSconfig = config.getProjectConfig().ios;
13 | const pw_iOSconfig = config.getDependencyConfig('pushwoosh-react-native-plugin').ios;
14 |
15 | const project = xcode.project(iOSconfig.pbxprojPath).parseSync();
16 |
17 | var targets = project.pbxNativeTargetSection();
18 |
19 | for (uuid in targets) {
20 | var libFiles = project.pbxFrameworksBuildPhaseObj(uuid).files;
21 | var filesCount = libFiles.length;
22 | for (var f = 0; f < filesCount; ++f) {
23 | var fileRef = project.pbxBuildFileSection()[libFiles[f].value].fileRef;
24 | var file = project.pbxFileReferenceSection()[fileRef];
25 | if (file != null) {
26 | if (file.path == 'libPushwooshPlugin.a') {
27 | createGroupWithMessage(project, 'Resources');
28 | project.addResourceFile(path.relative(iOSconfig.sourceDir, path.join(pw_iOSconfig.sourceDir, 'PushwooshInboxBundle.bundle')), {'target' : uuid }, null);
29 | }
30 | }
31 | }
32 | }
33 | fs.writeFileSync(
34 | iOSconfig.pbxprojPath,
35 | project.writeSync()
36 | );
37 | });
38 |
39 |
40 | };
41 |
42 | pwAddInboxiOSResources();
43 |
--------------------------------------------------------------------------------
/src/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | maven {
5 | url "https://maven.google.com"
6 | }
7 | }
8 |
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:4.1.3'
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | mavenCentral()
17 | maven {
18 | url "https://maven.google.com"
19 | }
20 | }
21 | }
22 |
23 | apply plugin: 'com.android.library'
24 |
25 | android {
26 | compileSdkVersion 33
27 | defaultConfig {
28 | minSdkVersion 21
29 | targetSdkVersion 33
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | }
38 |
39 | ext {
40 | pushwoosh = "6.7.24"
41 | }
42 |
43 | dependencies {
44 | implementation 'com.facebook.react:react-native:+'
45 | implementation "com.pushwoosh:pushwoosh:${pushwoosh}"
46 | implementation "com.pushwoosh:pushwoosh-firebase:${pushwoosh}"
47 | implementation "com.pushwoosh:pushwoosh-huawei:${pushwoosh}"
48 | implementation "com.pushwoosh:pushwoosh-amazon:${pushwoosh}"
49 | implementation "com.pushwoosh:pushwoosh-badge:${pushwoosh}"
50 | implementation "com.pushwoosh:pushwoosh-inbox:${pushwoosh}"
51 | implementation "com.pushwoosh:pushwoosh-inbox-ui:${pushwoosh}"
52 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.20"
53 | implementation "com.google.firebase:firebase-messaging:23.1.0"
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pushwoosh/pushwoosh-react-native-plugin/bf28d2027de84ad39175b566ebf2d7f969814d8a/src/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 22 10:34:23 NOVT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/src/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/src/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/src/android/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arellomobile/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/src/android/src/androidTest/java/com/pushwoosh/reactnativeplugin/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/src/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
11 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/ConversionUtil.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Iterator;
8 |
9 | import com.facebook.react.bridge.ReadableArray;
10 | import com.facebook.react.bridge.ReadableMap;
11 | import com.facebook.react.bridge.ReadableMapKeySetIterator;
12 | import com.facebook.react.bridge.ReadableType;
13 | import com.facebook.react.bridge.WritableArray;
14 | import com.facebook.react.bridge.WritableMap;
15 | import com.facebook.react.bridge.WritableNativeArray;
16 | import com.facebook.react.bridge.WritableNativeMap;
17 | import com.pushwoosh.inbox.data.InboxMessage;
18 | import com.pushwoosh.internal.utils.JsonUtils;
19 | import com.pushwoosh.internal.utils.PWLog;
20 | import com.pushwoosh.tags.TagsBundle;
21 |
22 | import org.json.JSONArray;
23 | import org.json.JSONException;
24 | import org.json.JSONObject;
25 |
26 | public final class ConversionUtil {
27 |
28 | public static TagsBundle convertToTagsBundle(ReadableMap readableMap) {
29 | return new TagsBundle.Builder()
30 | .putAll(toJsonObject(readableMap))
31 | .build();
32 | }
33 |
34 | public static JSONObject toJsonObject(ReadableMap readableMap) {
35 | ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
36 | JSONObject result = new JSONObject();
37 | while (iterator.hasNextKey()) {
38 | String key = iterator.nextKey();
39 | ReadableType type = readableMap.getType(key);
40 | try {
41 | switch (type) {
42 | case Null:
43 | result.put(key, JSONObject.NULL);
44 | break;
45 | case Boolean:
46 | result.put(key, readableMap.getBoolean(key));
47 | break;
48 | case Number:
49 | result.put(key, readableMap.getDouble(key));
50 | break;
51 | case String:
52 | result.put(key, readableMap.getString(key));
53 | break;
54 | case Map:
55 | result.put(key, toJsonObject(readableMap.getMap(key)));
56 | break;
57 | case Array:
58 | result.put(key, toArray(readableMap.getArray(key)));
59 | break;
60 | default:
61 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object with key: " + key + ".");
62 | }
63 |
64 | } catch (JSONException e) {
65 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object with key: " + key + ".", e);
66 | }
67 |
68 | }
69 | return result;
70 | }
71 |
72 | public static JSONArray toArray(ReadableArray readableArray) {
73 | JSONArray result = new JSONArray();
74 | for (int i = 0; i < readableArray.size(); i++) {
75 | ReadableType indexType = readableArray.getType(i);
76 | try {
77 | switch (indexType) {
78 | case Null:
79 | result.put(i, JSONObject.NULL);
80 | break;
81 | case Boolean:
82 | result.put(i, readableArray.getBoolean(i));
83 | break;
84 | case Number:
85 | result.put(i, readableArray.getDouble(i));
86 | break;
87 | case String:
88 | result.put(i, readableArray.getString(i));
89 | break;
90 | case Map:
91 | result.put(i, toJsonObject(readableArray.getMap(i)));
92 | break;
93 | case Array:
94 | result.put(i, toArray(readableArray.getArray(i)));
95 | break;
96 | default:
97 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".");
98 | }
99 | } catch (JSONException e) {
100 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".", e);
101 | }
102 | }
103 | return result;
104 | }
105 |
106 | public static JSONObject stringToJSONObject(String string) {
107 | try {
108 | JSONObject json = new JSONObject(string);
109 | return json;
110 | } catch (JSONException e) {
111 | PWLog.exception(e);
112 | }
113 |
114 | return new JSONObject();
115 | }
116 |
117 | public static WritableMap toWritableMap(JSONObject jsonObject) {
118 | WritableNativeMap result = new WritableNativeMap();
119 |
120 | Iterator keys = jsonObject.keys();
121 | while (keys.hasNext()) {
122 | String key = keys.next();
123 | try {
124 | Object value = jsonObject.get(key);
125 |
126 | if (value == null || JSONObject.NULL.equals(value)) {
127 | result.putNull(key);
128 | } else if (value instanceof JSONObject) {
129 | result.putMap(key, toWritableMap((JSONObject) value));
130 | } else if (value instanceof JSONArray) {
131 | result.putArray(key, toWritableArray((JSONArray) value));
132 | } else if (value instanceof Boolean) {
133 | result.putBoolean(key, (Boolean) value);
134 | } else if (value instanceof Integer) {
135 | result.putInt(key, (Integer) value);
136 | } else if (value instanceof Long) {
137 | result.putString(key, String.valueOf(value));
138 | } else if (value instanceof String) {
139 | result.putString(key, (String) value);
140 | } else if (value instanceof Double) {
141 | result.putDouble(key, (Double) value);
142 | } else {
143 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object " + value.toString());
144 | }
145 |
146 | } catch (JSONException e) {
147 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object with key " + key, e);
148 | }
149 | }
150 |
151 | return result;
152 | }
153 |
154 | public static WritableArray toWritableArray(JSONArray array) {
155 | WritableNativeArray result = new WritableNativeArray();
156 |
157 | for (int i = 0; i < array.length(); i++) {
158 | try {
159 | Object value = array.get(i);
160 | if (value == null) {
161 | result.pushNull();
162 | } else if (value instanceof JSONObject) {
163 | result.pushMap(toWritableMap((JSONObject) value));
164 | } else if (value instanceof JSONArray) {
165 | result.pushArray(toWritableArray((JSONArray) value));
166 | } else if (value instanceof Boolean) {
167 | result.pushBoolean((Boolean) value);
168 | } else if (value instanceof Integer) {
169 | result.pushInt((Integer) value);
170 | } else if (value instanceof Long) {
171 | result.pushString(String.valueOf(value));
172 | } else if (value instanceof String) {
173 | result.pushString((String) value);
174 | } else if (value instanceof Double) {
175 | result.pushDouble((Double) value);
176 | } else {
177 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object " + value.toString());
178 | }
179 | } catch (JSONException e) {
180 | e.printStackTrace();
181 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object with index i " + i + " in array " + array.toString(), e);
182 | }
183 | }
184 |
185 | return result;
186 | }
187 |
188 | public static WritableMap inboxMessageToWritableMap(InboxMessage message) {
189 | return toWritableMap(inboxMessageToJson(message));
190 | }
191 |
192 | public static JSONObject inboxMessageToJson(InboxMessage message) {
193 | JSONObject object = new JSONObject();
194 | try {
195 | object.put("code", message.getCode())
196 | .put("title", message.getTitle())
197 | .put("imageUrl", message.getImageUrl())
198 | .put("message",message.getMessage())
199 | .put("sendDate",message.getISO8601SendDate())
200 | .put("type", message.getType().getCode())
201 | .put("bannerUrl", message.getBannerUrl())
202 | .put("isRead",message.isRead())
203 | .put("actionParams",message.getActionParams())
204 | .put("isActionPerformed",message.isActionPerformed());
205 |
206 | Bundle bundle = JsonUtils.jsonStringToBundle( message.getActionParams());
207 | String customData = bundle.getString("u");
208 | if (customData != null) {
209 | object.put("customData", customData);
210 | }
211 | } catch (JSONException e) {
212 | Log.e("PushwooshInbox", "Failed to fetch inbox message :" + e.getMessage());
213 | }
214 | return object;
215 | }
216 |
217 | public static ArrayList messageCodesArrayToArrayList(ReadableArray readableArray) {
218 | ArrayList result = new ArrayList<>();
219 | for (int i = 0; i < readableArray.size(); i++) {
220 | ReadableType indexType = readableArray.getType(i);
221 | try {
222 | if (indexType == ReadableType.String) {
223 | result.add(readableArray.getString(i));
224 | } else {
225 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".");
226 | }
227 | } catch (Exception e) {
228 | PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".", e);
229 | }
230 | }
231 | return result;
232 | }
233 | }
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/CustomFirebaseMessagingService.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.plugin.pushnotifications;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.google.firebase.messaging.FirebaseMessagingService;
6 | import com.google.firebase.messaging.RemoteMessage;
7 | import com.pushwoosh.firebase.PushwooshFcmHelper;
8 |
9 | public class CustomFirebaseMessagingService extends FirebaseMessagingService {
10 | @Override
11 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
12 | if (PushwooshFcmHelper.isPushwooshMessage(remoteMessage)){
13 | PushwooshFcmHelper.onMessageReceived(this, remoteMessage);
14 | } else {
15 | //handle push from a different service here
16 | }
17 | }
18 |
19 | @Override
20 | public void onNewToken(@NonNull String s) {
21 | super.onNewToken(s);
22 | PushwooshFcmHelper.onTokenRefresh(s);
23 | sendTokenToAnotherService();
24 | }
25 |
26 | public void sendTokenToAnotherService() {
27 | //handle push registration of another service here
28 | }
29 | }
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/EventDispatcher.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import com.facebook.react.bridge.Callback;
9 | import com.facebook.react.bridge.ReactContext;
10 | import com.facebook.react.bridge.WritableMap;
11 | import com.facebook.react.modules.core.DeviceEventManagerModule;
12 |
13 | public class EventDispatcher {
14 |
15 | private Map> subscribers = new HashMap>();
16 |
17 | public void subscribe(String event, Callback callback) {
18 | if (callback == null) {
19 | return;
20 | }
21 |
22 | synchronized (subscribers) {
23 | if (!subscribers.containsKey(event)) {
24 | subscribers.put(event, new ArrayList());
25 | }
26 |
27 | List list = subscribers.get(event);
28 | list.add(callback);
29 | }
30 | }
31 |
32 | public void dispatchEvent(String event, Object... objects) {
33 | synchronized (subscribers) {
34 | if (!subscribers.containsKey(event)) {
35 | return;
36 | }
37 |
38 | List list = subscribers.get(event);
39 | for (Callback subscriber : list) {
40 | subscriber.invoke(objects);
41 | }
42 |
43 | // A native module is supposed to invoke its callback only once!
44 | list.clear();
45 | }
46 | }
47 |
48 | public void sendJSEvent(ReactContext reactContext, String event, WritableMap params) {
49 | reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
50 | .emit(event, params);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InboxUiStyleManager.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.drawable.BitmapDrawable;
7 | import android.graphics.drawable.Drawable;
8 |
9 | import com.facebook.react.bridge.ReadableMap;
10 | import com.pushwoosh.inbox.ui.PushwooshInboxStyle;
11 | import com.pushwoosh.inbox.ui.model.customizing.formatter.InboxDateFormatter;
12 |
13 | import java.io.IOException;
14 | import java.net.URL;
15 | import java.text.SimpleDateFormat;
16 | import java.util.Date;
17 | import java.util.Locale;
18 |
19 | class InboxUiStyleManager {
20 | private static final String LIST_ERROR_MESSAGE_KEY = "listErrorMessage";
21 | private static final String LIST_EMPTY_MESSAGE_KEY = "listEmptyMessage";
22 | private static final String DATE_FORMAT_KEY = "dateFormat";
23 | private static final String DEFAULT_IMAGE_ICON_KEY = "defaultImageIcon";
24 | private static final String LIST_ERROR_IMAGE_KEY = "listErrorImage";
25 | private static final String LIST_EMPTY_IMAGE_KEY = "listEmptyImage";
26 | private static final String ACCENT_COLOR_KEY = "accentColor";
27 | private static final String HIGHLIGHT_COLOR_KEY = "highlightColor";
28 | private static final String BACKGROUND_COLOR_KEY = "backgroundColor";
29 | private static final String DIVIDER_COLOR_KEY = "dividerColor";
30 | private static final String DATE_COLOR_KEY = "dateColor";
31 | private static final String READ_DATE_COLOR_KEY = "readDateColor";
32 | private static final String TITLE_COLOR_KEY = "titleColor";
33 | private static final String READ_TITLE_COLOR_KEY = "readTitleColor";
34 | private static final String DESCRIPTION_COLOR_KEY = "descriptionColor";
35 | private static final String READ_DESCRIPTION_COLOR_KEY = "readDescriptionColor";
36 | private static final String BAR_BACKGROUND_COLOR = "barBackgroundColor";
37 | private static final String BAR_ACCENT_COLOR = "barAccentColor";
38 | private static final String BAR_TEXT_COLOR = "barTextColor";
39 |
40 | public static final String URI_KEY = "uri";
41 |
42 | private Context context;
43 |
44 | public InboxUiStyleManager(Context context){
45 | this.context = context;
46 | }
47 |
48 | public void setStyle(ReadableMap mapStyle) {
49 | setDateFormat(mapStyle);
50 | setImages(mapStyle);
51 | setTexts(mapStyle);
52 | setColors(mapStyle);
53 | }
54 |
55 | private void setDateFormat(ReadableMap mapStyle) {
56 | if (!mapStyle.hasKey(DATE_FORMAT_KEY)) {
57 | return;
58 | }
59 | String dateFormat = mapStyle.getString(DATE_FORMAT_KEY);
60 | if (dateFormat != null && !dateFormat.isEmpty()) {
61 | ReactInboxDateFormatter inboxDateFormatter = new ReactInboxDateFormatter(dateFormat);
62 | PushwooshInboxStyle.INSTANCE.setDateFormatter(inboxDateFormatter);
63 | }
64 | }
65 |
66 | private void setTexts(ReadableMap mapStyle) {
67 | PushwooshInboxStyle PWInboxStyle = PushwooshInboxStyle.INSTANCE;
68 | if (mapStyle.hasKey(LIST_ERROR_MESSAGE_KEY))
69 | PWInboxStyle.setListErrorMessage(mapStyle.getString(LIST_ERROR_MESSAGE_KEY));
70 | if (mapStyle.hasKey(LIST_EMPTY_MESSAGE_KEY))
71 | PWInboxStyle.setListEmptyText(mapStyle.getString(LIST_EMPTY_MESSAGE_KEY));
72 | }
73 |
74 | private void setImages(ReadableMap mapStyle) {
75 | PushwooshInboxStyle PWInboxStyle = PushwooshInboxStyle.INSTANCE;
76 | Drawable defaultImageIcon = getImage(mapStyle, DEFAULT_IMAGE_ICON_KEY);
77 | if (defaultImageIcon != null)
78 | PWInboxStyle.setDefaultImageIconDrawable(defaultImageIcon);
79 |
80 | Drawable listErrorImage = getImage(mapStyle, LIST_ERROR_IMAGE_KEY);
81 | if (listErrorImage != null)
82 | PWInboxStyle.setListErrorImageDrawable(listErrorImage);
83 |
84 | Drawable listEmptyImage = getImage(mapStyle, LIST_EMPTY_IMAGE_KEY);
85 | if (listEmptyImage != null)
86 | PWInboxStyle.setListEmptyImageDrawable(listEmptyImage);
87 | }
88 |
89 | private Drawable getImage(ReadableMap mapStyle, String key) {
90 | if (!mapStyle.hasKey(key)) {
91 | return null;
92 | }
93 | ReadableMap defaultImageIcon = mapStyle.getMap(key);
94 | String uri = defaultImageIcon.getString(URI_KEY);
95 | try {
96 | return getDrawable(uri);
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return null;
101 | }
102 |
103 | private Drawable getDrawable(String uri) throws IOException {
104 | URL url = new URL(uri);
105 | Bitmap bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
106 | Drawable drawable = null;
107 | if (context != null) {
108 | drawable = new BitmapDrawable(context.getResources(), bitmap);
109 | }
110 | return drawable;
111 | }
112 |
113 | private void setColors(ReadableMap mapStyle) {
114 | PushwooshInboxStyle PWInboxStyle = PushwooshInboxStyle.INSTANCE;
115 |
116 | if (mapStyle.hasKey(ACCENT_COLOR_KEY))
117 | PWInboxStyle.setAccentColor(mapStyle.getInt(ACCENT_COLOR_KEY));
118 | if (mapStyle.hasKey(HIGHLIGHT_COLOR_KEY))
119 | PWInboxStyle.setHighlightColor(mapStyle.getInt(HIGHLIGHT_COLOR_KEY));
120 | if (mapStyle.hasKey(BACKGROUND_COLOR_KEY))
121 | PWInboxStyle.setBackgroundColor(mapStyle.getInt(BACKGROUND_COLOR_KEY));
122 | if (mapStyle.hasKey(DIVIDER_COLOR_KEY))
123 | PWInboxStyle.setDividerColor(mapStyle.getInt(DIVIDER_COLOR_KEY));
124 |
125 | if (mapStyle.hasKey(DATE_COLOR_KEY))
126 | PWInboxStyle.setDateColor(mapStyle.getInt(DATE_COLOR_KEY));
127 | if (mapStyle.hasKey(READ_DATE_COLOR_KEY))
128 | PWInboxStyle.setReadDateColor(mapStyle.getInt(READ_DATE_COLOR_KEY));
129 |
130 | if (mapStyle.hasKey(TITLE_COLOR_KEY))
131 | PWInboxStyle.setTitleColor(mapStyle.getInt(TITLE_COLOR_KEY));
132 | if (mapStyle.hasKey(READ_TITLE_COLOR_KEY))
133 | PWInboxStyle.setReadTitleColor(mapStyle.getInt(READ_TITLE_COLOR_KEY));
134 |
135 | if (mapStyle.hasKey(DESCRIPTION_COLOR_KEY))
136 | PWInboxStyle.setDescriptionColor(mapStyle.getInt(DESCRIPTION_COLOR_KEY));
137 | if (mapStyle.hasKey(READ_DESCRIPTION_COLOR_KEY))
138 | PWInboxStyle.setReadDescriptionColor(mapStyle.getInt(READ_DESCRIPTION_COLOR_KEY));
139 |
140 | if (mapStyle.hasKey(BAR_BACKGROUND_COLOR))
141 | PWInboxStyle.setBarBackgroundColor(mapStyle.getInt(BAR_BACKGROUND_COLOR));
142 | if (mapStyle.hasKey(BAR_ACCENT_COLOR))
143 | PWInboxStyle.setBarAccentColor(mapStyle.getInt(BAR_ACCENT_COLOR));
144 | if (mapStyle.hasKey(BAR_TEXT_COLOR))
145 | PWInboxStyle.setBarTextColor(mapStyle.getInt(BAR_TEXT_COLOR));
146 | }
147 |
148 | private class ReactInboxDateFormatter implements InboxDateFormatter {
149 |
150 | private SimpleDateFormat simpleDateFormat;
151 |
152 | public ReactInboxDateFormatter(String dateFormat) {
153 | Locale aDefault = Locale.getDefault();
154 | simpleDateFormat = new SimpleDateFormat(dateFormat, aDefault);
155 | }
156 |
157 | @Override
158 | public String transform(Date date) {
159 | return simpleDateFormat.format(date);
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InlineInAppManager.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import com.facebook.react.common.MapBuilder;
4 | import com.facebook.react.uimanager.SimpleViewManager;
5 | import com.facebook.react.uimanager.ThemedReactContext;
6 | import com.facebook.react.uimanager.annotations.ReactProp;
7 |
8 | import java.util.Map;
9 |
10 | public class InlineInAppManager extends SimpleViewManager {
11 | public static final String REACT_CLASS = "PWInlineInAppView";
12 |
13 | @Override
14 | public String getName() {
15 | return REACT_CLASS;
16 | }
17 |
18 | @Override
19 | public RCTInlineInAppView createViewInstance(ThemedReactContext context) {
20 | RCTInlineInAppView view = new RCTInlineInAppView(context);
21 | return view;
22 | }
23 |
24 | @ReactProp(name = "identifier")
25 | public void setIdentifier(final RCTInlineInAppView view, String identifier) {
26 | view.setIdentifier(identifier);
27 | }
28 |
29 | public Map getExportedCustomBubblingEventTypeConstants() {
30 | return MapBuilder.builder()
31 | .put(
32 | "onLoaded",
33 | MapBuilder.of(
34 | "phasedRegistrationNames",
35 | MapBuilder.of("bubbled", "onLoaded")))
36 | .put(
37 | "onClosed",
38 | MapBuilder.of(
39 | "phasedRegistrationNames",
40 | MapBuilder.of("bubbled", "onClosed")))
41 | .put(
42 | "onSizeChanged",
43 | MapBuilder.of(
44 | "phasedRegistrationNames",
45 | MapBuilder.of("bubbled", "onSizeChanged")))
46 | .build();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshNotificationServiceExtension.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.content.pm.ApplicationInfo;
4 | import android.content.pm.PackageManager;
5 |
6 | import com.pushwoosh.internal.utils.PWLog;
7 | import com.pushwoosh.notification.NotificationServiceExtension;
8 | import com.pushwoosh.notification.PushMessage;
9 |
10 | public class PushwooshNotificationServiceExtension extends NotificationServiceExtension {
11 |
12 | private boolean showForegroundPush;
13 |
14 | public PushwooshNotificationServiceExtension() {
15 | try {
16 | String packageName = getApplicationContext().getPackageName();
17 | ApplicationInfo ai = getApplicationContext().getPackageManager().getApplicationInfo(packageName, PackageManager.GET_META_DATA);
18 |
19 | if (ai.metaData != null) {
20 | showForegroundPush = ai.metaData.getBoolean("PW_BROADCAST_PUSH", true) || ai.metaData.getBoolean("com.pushwoosh.foreground_push", true);
21 | }
22 | } catch (Exception e) {
23 | PWLog.exception(e);
24 | }
25 |
26 | PWLog.debug(PushwooshPlugin.TAG, "showForegroundPush = " + showForegroundPush);
27 | }
28 |
29 | @Override
30 | protected boolean onMessageReceived(final PushMessage pushMessage) {
31 | PushwooshPlugin.messageReceived(pushMessage.toJson().toString());
32 | return (!showForegroundPush && isAppOnForeground()) || super.onMessageReceived(pushMessage);
33 | }
34 |
35 | @Override
36 | protected void startActivityForPushMessage(final PushMessage pushMessage) {
37 | super.startActivityForPushMessage(pushMessage);
38 | }
39 |
40 | @Override
41 | protected void onMessageOpened(final PushMessage pushMessage) {
42 | PushwooshPlugin.openPush(pushMessage.toJson().toString());
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPackage.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.view.ViewManager;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class PushwooshPackage implements ReactPackage {
16 | // Deprecated from RN 0.47
17 | public List> createJSModules() {
18 | return Collections.emptyList();
19 | }
20 |
21 | @Override
22 | public List createViewManagers(ReactApplicationContext reactContext) {
23 | return Arrays.asList(new InlineInAppManager());
24 | }
25 |
26 | @Override
27 | public List createNativeModules(
28 | ReactApplicationContext reactContext) {
29 | List modules = new ArrayList<>();
30 |
31 | modules.add(new PushwooshPlugin(reactContext));
32 |
33 | return modules;
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.graphics.Color;
8 | import android.text.TextUtils;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 |
13 | import com.facebook.react.bridge.Callback;
14 | import com.facebook.react.bridge.LifecycleEventListener;
15 | import com.facebook.react.bridge.ReactApplicationContext;
16 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
17 | import com.facebook.react.bridge.ReactMethod;
18 | import com.facebook.react.bridge.ReadableArray;
19 | import com.facebook.react.bridge.ReadableMap;
20 | import com.facebook.react.bridge.WritableNativeArray;
21 | import com.pushwoosh.GDPRManager;
22 | import com.pushwoosh.Pushwoosh;
23 | import com.pushwoosh.RegisterForPushNotificationsResultData;
24 | import com.pushwoosh.badge.PushwooshBadge;
25 | import com.pushwoosh.exception.GetTagsException;
26 | import com.pushwoosh.exception.PushwooshException;
27 | import com.pushwoosh.exception.SetEmailException;
28 | import com.pushwoosh.exception.SetUserException;
29 | import com.pushwoosh.exception.SetUserIdException;
30 | import com.pushwoosh.exception.RegisterForPushNotificationsException;
31 | import com.pushwoosh.exception.UnregisterForPushNotificationException;
32 | import com.pushwoosh.function.Result;
33 | import com.pushwoosh.inapp.PushwooshInApp;
34 | import com.pushwoosh.inbox.PushwooshInbox;
35 | import com.pushwoosh.inbox.data.InboxMessage;
36 | import com.pushwoosh.inbox.exception.InboxMessagesException;
37 | import com.pushwoosh.inbox.ui.presentation.view.activity.InboxActivity;
38 | import com.pushwoosh.internal.network.NetworkModule;
39 | import com.pushwoosh.internal.platform.AndroidPlatformModule;
40 | import com.pushwoosh.internal.utils.PWLog;
41 | import com.pushwoosh.notification.PushwooshNotificationSettings;
42 | import com.pushwoosh.notification.SoundType;
43 | import com.pushwoosh.notification.VibrateType;
44 | import com.pushwoosh.tags.TagsBundle;
45 | import com.pushwoosh.notification.LocalNotification;
46 | import com.pushwoosh.notification.LocalNotificationReceiver;
47 |
48 | import org.json.JSONObject;
49 |
50 | import java.util.ArrayList;
51 | import java.util.Collection;
52 |
53 | public class PushwooshPlugin extends ReactContextBaseJavaModule implements LifecycleEventListener {
54 |
55 | static final String TAG = "ReactNativePlugin";
56 | private static final String PUSH_OPEN_EVENT = "PwPushOpened";
57 | private static final String PUSH_OPEN_JS_EVENT = "pushOpened";
58 |
59 | private static final String PUSH_RECEIVED_EVENT = Pushwoosh.PUSH_RECEIVE_EVENT;
60 | private static final String PUSH_RECEIVED_JS_EVENT = "pushReceived";
61 |
62 | private static EventDispatcher mEventDispatcher = new EventDispatcher();
63 |
64 | private static String sReceivedPushData;
65 | private static boolean sReceivedPushCallbackRegistered = false;
66 |
67 | private static String sStartPushData;
68 | private static boolean sPushCallbackRegistered = false;
69 |
70 | private static boolean sInitialized = false;
71 | private static final Object sStartPushLock = new Object();
72 |
73 | private static PushwooshPlugin INSTANCE = null;
74 |
75 | private InboxUiStyleManager inboxUiInboxUiStyleManager;
76 |
77 | public PushwooshPlugin(ReactApplicationContext reactContext) {
78 | super(reactContext);
79 |
80 | INSTANCE = this;
81 |
82 | reactContext.addLifecycleEventListener(this);
83 |
84 | Context applicationContext = AndroidPlatformModule.getApplicationContext();
85 | inboxUiInboxUiStyleManager = new InboxUiStyleManager(applicationContext);
86 | }
87 |
88 | ///
89 | /// Module API
90 | ///
91 |
92 | @Override
93 | public String getName() {
94 | return "Pushwoosh";
95 | }
96 |
97 |
98 | @ReactMethod
99 | public void init(ReadableMap config, Callback success, Callback error) {
100 | String appId = config.getString("pw_appid");
101 | String projectId = config.getString("project_number");
102 |
103 | if (appId == null || projectId == null) {
104 | if (error != null) {
105 | error.invoke("Pushwoosh Application id and GCM project number not specified");
106 | }
107 | return;
108 | }
109 |
110 | if (config.hasKey("reverse_proxy_url")) {
111 | String proxyUrl = config.getString("reverse_proxy_url");
112 | if (!TextUtils.isEmpty(proxyUrl) && NetworkModule.getRequestManager() != null) {
113 | NetworkModule.getRequestManager().setReverseProxyUrl(proxyUrl);
114 | }
115 | }
116 |
117 | Pushwoosh.getInstance().setAppId(appId);
118 |
119 | if (!TextUtils.isEmpty(projectId)) {
120 | Pushwoosh.getInstance().setSenderId(projectId);
121 | }
122 |
123 | synchronized (sStartPushLock) {
124 | if (sReceivedPushData != null) {
125 | sendEvent(PUSH_RECEIVED_JS_EVENT, ConversionUtil.stringToJSONObject(sReceivedPushData));
126 | }
127 |
128 | if (sStartPushData != null) {
129 | sendEvent(PUSH_OPEN_JS_EVENT, ConversionUtil.stringToJSONObject(sStartPushData));
130 | }
131 | }
132 |
133 | sInitialized = true;
134 |
135 | if (success != null) {
136 | success.invoke();
137 | }
138 | }
139 |
140 | @ReactMethod
141 | public void register(final Callback success, final Callback error) {
142 | Pushwoosh.getInstance().registerForPushNotifications(new RegisterForPushNotificationCallback(success, error));
143 | }
144 |
145 | @ReactMethod
146 | public void unregister(final Callback success, final Callback error) {
147 | Pushwoosh.getInstance().unregisterForPushNotifications(new com.pushwoosh.function.Callback() {
148 | @Override
149 | public void process(Result result) {
150 | if (result.isSuccess()) {
151 | if (success != null) {
152 | success.invoke(result.getData());
153 | }
154 | } else if (result.getException() != null) {
155 | if (error != null) {
156 | error.invoke(result.getException().getLocalizedMessage());
157 | }
158 | }
159 | }
160 | });
161 | }
162 |
163 | @ReactMethod
164 | public void onPushOpen(Callback callback) {
165 | synchronized (sStartPushLock) {
166 | if (!sPushCallbackRegistered && sStartPushData != null) {
167 | callback.invoke(ConversionUtil.toWritableMap(ConversionUtil.stringToJSONObject(sStartPushData)));
168 | sPushCallbackRegistered = true;
169 | return;
170 | }
171 |
172 | sPushCallbackRegistered = true;
173 | mEventDispatcher.subscribe(PUSH_OPEN_EVENT, callback);
174 | }
175 | }
176 |
177 | @ReactMethod
178 | public void onPushReceived(Callback callback) {
179 | synchronized (sStartPushLock) {
180 | if (!sReceivedPushCallbackRegistered && sReceivedPushData != null) {
181 | callback.invoke(ConversionUtil.toWritableMap(ConversionUtil.stringToJSONObject(sReceivedPushData)));
182 | sReceivedPushCallbackRegistered = true;
183 | return;
184 | }
185 |
186 | sReceivedPushCallbackRegistered = true;
187 | mEventDispatcher.subscribe(PUSH_RECEIVED_EVENT, callback);
188 | }
189 | }
190 |
191 | @ReactMethod
192 | public void addListener(String eventName) {
193 | // Required for NativeEventEmitter. No need to do anything here.
194 | }
195 |
196 | @ReactMethod
197 | public void removeListeners(Integer count) {
198 | // Required for NativeEventEmitter. No need to do anything here.
199 | }
200 |
201 |
202 | @ReactMethod
203 | public void setEmails(@NonNull ReadableArray emails, final Callback success, final Callback error) {
204 | Pushwoosh.getInstance().setEmail(ConversionUtil.messageCodesArrayToArrayList(emails), new com.pushwoosh.function.Callback() {
205 | @Override
206 | public void process(@NonNull Result result) {
207 | if (result.isSuccess()) {
208 | if (success != null) {
209 | success.invoke();
210 | }
211 | } else {
212 | if (error != null) {
213 | error.invoke(result.getException().getMessage());
214 | }
215 | }
216 | }
217 | });
218 | }
219 |
220 | @ReactMethod
221 | public void setUserEmails(@NonNull String userId, @NonNull ReadableArray emails, final Callback success, final Callback error) {
222 | Pushwoosh.getInstance().setUser(userId, ConversionUtil.messageCodesArrayToArrayList(emails), new com.pushwoosh.function.Callback() {
223 | @Override
224 | public void process(@NonNull Result result) {
225 | if (result.isSuccess()) {
226 | if (success != null) {
227 | success.invoke();
228 | }
229 | } else {
230 | if (error != null) {
231 | error.invoke(result.getException().getMessage());
232 | }
233 | }
234 | }
235 | });
236 | }
237 |
238 | @ReactMethod
239 | public void setTags(ReadableMap tags, final Callback success, final Callback error) {
240 | Pushwoosh.getInstance().sendTags(ConversionUtil.convertToTagsBundle(tags), new com.pushwoosh.function.Callback() {
241 | @Override
242 | public void process(Result result) {
243 | if (result.isSuccess()) {
244 | if (success != null) {
245 | success.invoke();
246 | }
247 | } else {
248 | if (error != null) {
249 | error.invoke(result.getException().getMessage());
250 | }
251 | }
252 | }
253 | });
254 | }
255 |
256 | @ReactMethod
257 | public void getTags(final Callback success, final Callback error) {
258 | Pushwoosh.getInstance().getTags(new com.pushwoosh.function.Callback() {
259 | @Override
260 | public void process(Result result) {
261 | if (result.isSuccess()) {
262 | if (success != null && result.getData() != null) {
263 | success.invoke(ConversionUtil.toWritableMap(result.getData().toJson()));
264 | }
265 | } else {
266 | if (error != null && result.getException() != null) {
267 | error.invoke(result.getException().getMessage());
268 | }
269 | }
270 | }
271 | });
272 | }
273 |
274 | @ReactMethod
275 | public void getPushToken(Callback callback) {
276 | callback.invoke(Pushwoosh.getInstance().getPushToken());
277 | }
278 |
279 | @ReactMethod
280 | public void getHwid(Callback callback) {
281 | callback.invoke(Pushwoosh.getInstance().getHwid());
282 | }
283 |
284 | @ReactMethod
285 | public void getUserId(Callback callback) {
286 | callback.invoke(Pushwoosh.getInstance().getUserId());
287 | }
288 |
289 | @ReactMethod
290 | public void setUserId(String userId, final Callback success, final Callback error) {
291 | Pushwoosh.getInstance().setUserId(userId, new com.pushwoosh.function.Callback() {
292 | @Override
293 | public void process(Result result) {
294 | if (result.isSuccess()) {
295 | if (success != null) {
296 | success.invoke();
297 | }
298 | } else {
299 | if (error != null) {
300 | error.invoke(result.getException().getMessage());
301 | }
302 | }
303 | }
304 | });
305 | }
306 |
307 | @ReactMethod
308 | public void postEvent(String event, ReadableMap attributes) {
309 | PushwooshInApp.getInstance().postEvent(event, ConversionUtil.convertToTagsBundle(attributes));
310 | }
311 |
312 | @ReactMethod
313 | public void createLocalNotification(ReadableMap data){
314 |
315 | JSONObject params = ConversionUtil.toJsonObject(data);
316 |
317 | String message = params.optString("msg");
318 | if (message == null){
319 | return;
320 | }
321 | int seconds = params.optInt("seconds");
322 | Bundle extras = new Bundle();
323 | String userData = params.optString("userData");
324 | if (userData!=null){
325 | extras.putString("u", userData);
326 | }
327 |
328 | LocalNotification.Builder builder = new LocalNotification.Builder();
329 | if (extras != null){
330 | builder.setExtras(extras);
331 | }
332 | LocalNotification notification = builder
333 | .setMessage(message)
334 | .setDelay(seconds)
335 | .build();
336 |
337 | Pushwoosh.getInstance().scheduleLocalNotification(notification);
338 | }
339 |
340 | @ReactMethod
341 | public void clearLocalNotification(){
342 | LocalNotificationReceiver.cancelAll();
343 | }
344 |
345 | @ReactMethod
346 | public void clearNotificationCenter() {
347 | if (AndroidPlatformModule.getManagerProvider() != null) {
348 | if (AndroidPlatformModule.getManagerProvider().getNotificationManager() != null) {
349 | AndroidPlatformModule.getManagerProvider().getNotificationManager().cancelAll();
350 | }
351 | }
352 | }
353 |
354 | @ReactMethod
355 | public void setApplicationIconBadgeNumber(int badgeNumber) {
356 | PushwooshBadge.setBadgeNumber(badgeNumber);
357 | }
358 |
359 | @ReactMethod
360 | public void getApplicationIconBadgeNumber(Callback callback) {
361 | callback.invoke(PushwooshBadge.getBadgeNumber());
362 | }
363 |
364 | @ReactMethod
365 | public void addToApplicationIconBadgeNumber(int badgeNumber) {
366 | PushwooshBadge.addBadgeNumber(badgeNumber);
367 | }
368 |
369 | @ReactMethod
370 | public void setMultiNotificationMode(boolean on) {
371 | PushwooshNotificationSettings.setMultiNotificationMode(on);
372 | }
373 |
374 | @ReactMethod
375 | public void setLightScreenOnNotification(boolean on) {
376 | PushwooshNotificationSettings.setLightScreenOnNotification(on);
377 | }
378 |
379 | @ReactMethod
380 | public void setEnableLED(boolean on) {
381 | PushwooshNotificationSettings.setEnableLED(on);
382 | }
383 |
384 | @ReactMethod
385 | public void setColorLED(int color) {
386 | PushwooshNotificationSettings.setColorLED(color);
387 | }
388 |
389 | @ReactMethod
390 | public void setSoundType(int type) {
391 | PushwooshNotificationSettings.setSoundNotificationType(SoundType.fromInt(type));
392 | }
393 |
394 | @ReactMethod
395 | public void setVibrateType(int type) {
396 | PushwooshNotificationSettings.setVibrateNotificationType(VibrateType.fromInt(type));
397 | }
398 |
399 |
400 | @ReactMethod
401 | public void presentInboxUI(final ReadableMap mapStyle) {
402 | if (mapStyle != null) {
403 | inboxUiInboxUiStyleManager.setStyle(mapStyle);
404 | }
405 |
406 | Activity currentActivity = getCurrentActivity();
407 | Intent intent = new Intent(currentActivity, InboxActivity.class);
408 | if (currentActivity != null) {
409 | currentActivity.startActivity(intent);
410 | }else {
411 | PWLog.error(TAG, "current activity is null");
412 | }
413 | }
414 |
415 | @ReactMethod
416 | public void messagesWithNoActionPerformedCount(final Callback callback) {
417 | PushwooshInbox.messagesWithNoActionPerformedCount(new com.pushwoosh.function.Callback() {
418 | @Override
419 | public void process(@NonNull Result result) {
420 | if (result.isSuccess() && callback != null) {
421 | callback.invoke(result.getData());
422 | }
423 | }
424 | });
425 | }
426 |
427 | @ReactMethod
428 | public void unreadMessagesCount(final Callback callback) {
429 | PushwooshInbox.unreadMessagesCount(new com.pushwoosh.function.Callback() {
430 | @Override
431 | public void process(@NonNull Result result) {
432 | if (result.isSuccess() && callback != null) {
433 | callback.invoke(result.getData());
434 | }
435 | }
436 | });
437 | }
438 |
439 | @ReactMethod
440 | public void messagesCount(final Callback callback) {
441 | PushwooshInbox.messagesCount(new com.pushwoosh.function.Callback() {
442 | @Override
443 | public void process(@NonNull Result result) {
444 | if (result.isSuccess() && callback != null) {
445 | callback.invoke(result.getData());
446 | }
447 | }
448 | });
449 | }
450 |
451 | @ReactMethod
452 | public void loadMessages(@NonNull final Callback success, @Nullable final Callback error) {
453 | PushwooshInbox.loadMessages(new com.pushwoosh.function.Callback, InboxMessagesException>() {
454 | @Override
455 | public void process(@NonNull Result, InboxMessagesException> result) {
456 | try {
457 | if (result.isSuccess() && result.getData() != null) {
458 | ArrayList messagesList = new ArrayList<>(result.getData());
459 | WritableNativeArray writableArray = new WritableNativeArray();
460 | for (InboxMessage message : messagesList) {
461 | writableArray.pushMap(ConversionUtil.inboxMessageToWritableMap(message));
462 | }
463 | success.invoke(writableArray);
464 | } else if (error != null) {
465 | error.invoke(TAG + "Failed to fetch inbox messages from server");
466 | }
467 | } catch (Exception e) {
468 | if (error != null) {
469 | error.invoke(e.getLocalizedMessage());
470 | }
471 | }
472 | }
473 | });
474 | }
475 |
476 | @ReactMethod
477 | public void readMessage(String id) {
478 | PushwooshInbox.readMessage(id);
479 | }
480 |
481 | @ReactMethod
482 | public void readMessages(ReadableArray codes) {
483 | PushwooshInbox.readMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
484 | }
485 |
486 | @ReactMethod
487 | public void deleteMessage(String id) {
488 | PushwooshInbox.deleteMessage(id);
489 | }
490 |
491 | @ReactMethod
492 | public void deleteMessages(ReadableArray codes) {
493 | PushwooshInbox.deleteMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
494 | }
495 |
496 | @ReactMethod
497 | public void performAction(String id) {
498 | PushwooshInbox.performAction(id);
499 | }
500 |
501 | @ReactMethod
502 | public void showGDPRConsentUI(){
503 | GDPRManager.getInstance().showGDPRConsentUI();
504 | }
505 |
506 | @ReactMethod
507 | public void showGDPRDeletionUI(){
508 | GDPRManager.getInstance().showGDPRDeletionUI();
509 | }
510 |
511 | @ReactMethod
512 | public void isDeviceDataRemoved(final Callback success){
513 | success.invoke(GDPRManager.getInstance().isDeviceDataRemoved());
514 | }
515 |
516 | @ReactMethod
517 | public void isCommunicationEnabled(final Callback success){
518 | success.invoke(GDPRManager.getInstance().isCommunicationEnabled());
519 | }
520 |
521 | @ReactMethod
522 | public void isAvailableGDPR(final Callback success){
523 | success.invoke(GDPRManager.getInstance().isAvailable());
524 | }
525 |
526 | @ReactMethod
527 | public void setCommunicationEnabled(boolean enable, final Callback success, final Callback error) {
528 | GDPRManager.getInstance().setCommunicationEnabled(enable, new com.pushwoosh.function.Callback() {
529 | @Override
530 | public void process(Result result) {
531 | if (result.isSuccess()) {
532 | if (success != null) {
533 | success.invoke(result.getData());
534 | }
535 | } else if (result.getException() != null) {
536 | if (error != null) {
537 | error.invoke(result.getException().getLocalizedMessage());
538 | }
539 | }
540 | }
541 | });
542 | }
543 |
544 | @ReactMethod
545 | public void removeAllDeviceData(final Callback success, final Callback error) {
546 | GDPRManager.getInstance().removeAllDeviceData(new com.pushwoosh.function.Callback() {
547 | @Override
548 | public void process(Result result) {
549 | if (result.isSuccess()) {
550 | if (success != null) {
551 | success.invoke(result.getData());
552 | }
553 | } else if (result.getException() != null) {
554 | if (error != null) {
555 | error.invoke(result.getException().getLocalizedMessage());
556 | }
557 | }
558 | }
559 | });
560 | }
561 |
562 | @ReactMethod
563 | public void setLanguage(String language){
564 | Pushwoosh.getInstance().setLanguage(language);
565 | }
566 |
567 | @ReactMethod
568 | public void setNotificationIconBackgroundColor(String color) {
569 | int intColor;
570 | try {
571 | intColor = Color.parseColor(color);
572 | PushwooshNotificationSettings.setNotificationIconBackgroundColor(intColor);
573 | } catch (IllegalArgumentException e) {
574 | PWLog.exception(e);
575 | }
576 | }
577 |
578 | @ReactMethod
579 | public void enableHuaweiPushNotifications() {
580 | Pushwoosh.getInstance().enableHuaweiPushNotifications();
581 | }
582 |
583 | ///
584 | /// LifecycleEventListener callbacks
585 | ///
586 |
587 | @Override
588 | public void onHostResume() {
589 | PWLog.noise(TAG, "Host resumed");
590 | }
591 |
592 | @Override
593 | public void onHostPause() {
594 | PWLog.noise(TAG, "Host paused");
595 | }
596 |
597 | @Override
598 | public void onHostDestroy() {
599 | PWLog.noise(TAG, "Host destroyed");
600 |
601 | sPushCallbackRegistered = false;
602 | sStartPushData = null;
603 |
604 | sReceivedPushCallbackRegistered = false;
605 | sReceivedPushData = null;
606 | }
607 |
608 | ///
609 | /// Private methods
610 | ///
611 |
612 | static void openPush(String pushData) {
613 | PWLog.info(TAG, "Push open: " + pushData);
614 |
615 | try {
616 | synchronized (sStartPushLock) {
617 | sStartPushData = pushData;
618 | if (sPushCallbackRegistered) {
619 | mEventDispatcher.dispatchEvent(PUSH_OPEN_EVENT, ConversionUtil.toWritableMap(ConversionUtil.stringToJSONObject(pushData)));
620 | }
621 | if (sInitialized && INSTANCE != null) {
622 | INSTANCE.sendEvent(PUSH_OPEN_JS_EVENT, ConversionUtil.stringToJSONObject(pushData));
623 | }
624 | }
625 | } catch (Exception e) {
626 | // React Native is highly unstable
627 | PWLog.exception(e);
628 | }
629 | }
630 |
631 | private void sendEvent(String event, JSONObject params) {
632 | mEventDispatcher.sendJSEvent(getReactApplicationContext(), event, ConversionUtil.toWritableMap(params));
633 | }
634 |
635 | static void messageReceived(String pushData) {
636 | PWLog.info(TAG, "Push received: " + pushData);
637 |
638 | try {
639 | synchronized (sStartPushLock) {
640 | sReceivedPushData = pushData;
641 | if (sReceivedPushCallbackRegistered) {
642 | mEventDispatcher.dispatchEvent(PUSH_RECEIVED_EVENT, ConversionUtil.toWritableMap(ConversionUtil.stringToJSONObject(pushData)));
643 | }
644 | if (sInitialized && INSTANCE != null) {
645 | INSTANCE.sendEvent(PUSH_RECEIVED_JS_EVENT, ConversionUtil.stringToJSONObject(pushData));
646 | }
647 | }
648 | } catch (Exception e) {
649 | // React Native is highly unstable
650 | PWLog.exception(e);
651 | }
652 | }
653 |
654 | private class RegisterForPushNotificationCallback implements com.pushwoosh.function.Callback {
655 | private Callback success;
656 | private Callback error;
657 |
658 | public RegisterForPushNotificationCallback(Callback success, Callback error) {
659 | this.success = success;
660 | this.error = error;
661 | }
662 |
663 | @Override
664 | public void process(Result result) {
665 | if (result.isSuccess()) {
666 | if (success != null && result.getData() != null) {
667 | success.invoke(result.getData().getToken());
668 | success = null;
669 | }
670 | } else if (result.getException() != null) {
671 | if (error != null) {
672 | error.invoke(result.getException().getLocalizedMessage());
673 | error = null;
674 | }
675 | }
676 | }
677 | }
678 | }
679 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/RCTInlineInAppView.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin;
2 |
3 | import android.content.Context;
4 | import android.view.Choreographer;
5 | import android.view.View;
6 |
7 | import com.facebook.react.bridge.Arguments;
8 | import com.facebook.react.bridge.ReactContext;
9 | import com.facebook.react.bridge.WritableMap;
10 | import com.facebook.react.uimanager.events.RCTEventEmitter;
11 | import com.pushwoosh.inapp.view.inline.InlineInAppView;
12 | import com.pushwoosh.inapp.view.inline.InlineInAppViewListener;
13 |
14 | public class RCTInlineInAppView extends InlineInAppView implements InlineInAppViewListener {
15 | public RCTInlineInAppView(Context context) {
16 | super(context);
17 | this.addInlineInAppViewListener(this);
18 | setupLayoutHack();
19 | }
20 |
21 | void setupLayoutHack() {
22 | Choreographer.getInstance().postFrameCallback(new Choreographer.FrameCallback() {
23 | @Override
24 | public void doFrame(long frameTimeNanos) {
25 | manuallyLayoutChildren();
26 | getViewTreeObserver().dispatchOnGlobalLayout();
27 | Choreographer.getInstance().postFrameCallback(this);
28 | }
29 | });
30 |
31 | }
32 |
33 | void manuallyLayoutChildren() {
34 | for (int i = 0; i < getChildCount(); i++) {
35 | View child = getChildAt(i);
36 | child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
37 | MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
38 | child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
39 | }
40 | }
41 |
42 | @Override
43 | public void onInlineInAppLoaded() {
44 | WritableMap event = Arguments.createMap();
45 | event.putString("identifier", this.getIdentifier());
46 | ReactContext reactContext = (ReactContext)getContext();
47 | reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
48 | getId(),
49 | "onLoaded",
50 | event);
51 | }
52 |
53 | @Override
54 | public void onInlineInAppViewClosed() {
55 | WritableMap event = Arguments.createMap();
56 | event.putString("identifier", this.getIdentifier());
57 | ReactContext reactContext = (ReactContext)getContext();
58 | reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
59 | getId(),
60 | "onClosed",
61 | event);
62 | }
63 |
64 | @Override
65 | public void onInlineInAppViewChangedSize(int var1, int var2) {
66 | WritableMap event = Arguments.createMap();
67 | event.putString("width", String.valueOf(var1));
68 | event.putString("height", String.valueOf(var2));
69 | ReactContext reactContext = (ReactContext)getContext();
70 | reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
71 | getId(),
72 | "onSizeChanged",
73 | event);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/android/src/main/java/com/pushwoosh/reactnativeplugin/internal/ReactNativePluginProvider.java:
--------------------------------------------------------------------------------
1 | package com.pushwoosh.reactnativeplugin.internal;
2 |
3 | import com.pushwoosh.internal.PluginProvider;
4 |
5 | public class ReactNativePluginProvider implements PluginProvider {
6 | @Override
7 | public String getPluginType() {
8 | return "React Native";
9 | }
10 |
11 | @Override
12 | public int richMediaStartDelay() {
13 | return DEFAULT_RICH_MEDIA_START_DELAY;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PushwooshPlugin
3 |
4 |
--------------------------------------------------------------------------------
/src/ios/PushwooshPlugin/PWEventDispatcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // PWEventDispatcher.h
3 | // Pushwoosh React Native Plugin
4 | // (c) Pushwoosh 2016
5 | //
6 |
7 | #import
8 |
9 | #import
10 |
11 | @interface PWEventDispatcher : NSObject
12 |
13 | + (instancetype)sharedDispatcher;
14 |
15 | - (void)subscribe:(RCTResponseSenderBlock)callback toEvent:(NSString*)event;
16 |
17 | - (void)dispatchEvent:(NSString*)event withArgs:(NSArray*)args;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/src/ios/PushwooshPlugin/PWEventDispatcher.m:
--------------------------------------------------------------------------------
1 | //
2 | // PWEventDispatcher.m
3 | // Pushwoosh React Native Plugin
4 | // (c) Pushwoosh 2016
5 | //
6 |
7 | #import "PWEventDispatcher.h"
8 |
9 | @interface PWEventDispatcher()
10 |
11 | @property (nonatomic, strong) NSMutableDictionary *subscribers;
12 |
13 | @end
14 |
15 | @implementation PWEventDispatcher
16 |
17 | - (id)init {
18 | self = [super init];
19 | if (self) {
20 | _subscribers = [NSMutableDictionary new];
21 | }
22 | return self;
23 | }
24 |
25 | + (instancetype)sharedDispatcher {
26 | static dispatch_once_t onceToken;
27 | static PWEventDispatcher *instance;
28 | dispatch_once(&onceToken, ^{
29 | instance = [PWEventDispatcher new];
30 | });
31 |
32 | return instance;
33 | }
34 |
35 | - (void)subscribe:(RCTResponseSenderBlock)callback toEvent:(NSString*)event {
36 | if (!callback) {
37 | return;
38 | }
39 |
40 | @synchronized(_subscribers) {
41 | if (!_subscribers[event]) {
42 | _subscribers[event] = [NSMutableArray new];
43 | }
44 |
45 | NSMutableArray *eventSubscribers = _subscribers[event];
46 | [eventSubscribers addObject:callback];
47 | }
48 | }
49 |
50 | - (void)dispatchEvent:(NSString*)event withArgs:(NSArray*)args {
51 | @synchronized(_subscribers) {
52 | NSMutableArray *eventSubscribers = _subscribers[event];
53 | for (RCTResponseSenderBlock callback in eventSubscribers) {
54 | callback(args);
55 | }
56 |
57 | // A native module is supposed to invoke its callback only once!
58 | [eventSubscribers removeAllObjects];
59 | }
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/src/ios/PushwooshPlugin/PWInlineInAppManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // PWInlineInAppManager.h
3 | // pushwoosh-react-native-plugin
4 | //
5 | // Created by Fectum on 15/01/2020.
6 | //
7 |
8 | #import "RCTViewManager.h"
9 | #import "Pushwoosh.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface PWInlineInAppManager : RCTViewManager
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/src/ios/PushwooshPlugin/PWInlineInAppManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // PWInlineInAppManager.m
3 | // pushwoosh-react-native-plugin
4 | //
5 | // Created by Fectum on 15/01/2020.
6 | //
7 |
8 | #import "PWInlineInAppManager.h"
9 |
10 | @interface PWReactInlineInAppView: PWInlineInAppView
11 |
12 | @property (nonatomic) RCTBubblingEventBlock onLoaded;
13 | @property (nonatomic) RCTBubblingEventBlock onClosed;
14 | @property (nonatomic) RCTBubblingEventBlock onSizeChanged;
15 |
16 | @end
17 |
18 | @implementation PWReactInlineInAppView
19 | @end
20 |
21 | @implementation PWInlineInAppManager
22 |
23 | RCT_EXPORT_MODULE(PWInlineInAppView)
24 |
25 | - (UIView *)view {
26 | PWReactInlineInAppView *view = [PWReactInlineInAppView new];
27 | view.delegate = self;
28 | return view;
29 | }
30 |
31 | RCT_EXPORT_VIEW_PROPERTY(identifier, NSString)
32 | RCT_EXPORT_VIEW_PROPERTY(onLoaded, RCTBubblingEventBlock)
33 | RCT_EXPORT_VIEW_PROPERTY(onClosed, RCTBubblingEventBlock)
34 | RCT_EXPORT_VIEW_PROPERTY(onSizeChanged, RCTBubblingEventBlock)
35 |
36 | - (void)inlineInAppDidLoadInView:(PWReactInlineInAppView *)inAppView {
37 | if (inAppView.onLoaded) {
38 | inAppView.onLoaded(@{@"identifier": inAppView.identifier});
39 | }
40 | }
41 |
42 | - (void)didCloseInlineInAppView:(PWReactInlineInAppView *)inAppView {
43 | if (inAppView.onClosed) {
44 | inAppView.onClosed(@{@"identifier": inAppView.identifier});
45 | }
46 | }
47 |
48 | - (void)didChangeSizeOfInlineInAppView:(PWReactInlineInAppView *)inAppView {
49 | if (inAppView.onSizeChanged) {
50 | inAppView.onSizeChanged(@{@"width": @(inAppView.bounds.size.width), @"height": @(inAppView.bounds.size.height)});
51 | }
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/src/ios/PushwooshPlugin/Pushwoosh.h:
--------------------------------------------------------------------------------
1 | //
2 | // Pushwoosh.h
3 | // Pushwoosh React Native Plugin
4 | // (c) Pushwoosh 2016
5 | //
6 |
7 | #import
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | #if __has_include()
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import
19 | #import
20 | #else
21 | #import "PushNotificationManager.h"
22 | #import "PWInAppManager.h"
23 | #import "PushwooshInboxUI.h"
24 | #import "PWGDPRManager.h"
25 | #import "PWInlineInAppView.h"
26 | #import "PWInbox.h"
27 | #endif
28 |
29 | @interface PushwooshPlugin: RCTEventEmitter
30 |
31 | @end
32 |
--------------------------------------------------------------------------------