pushwoosh-react-native-plugin 6.1.52 → 6.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +308 -40
- package/index.js +188 -23
- package/package.json +1 -1
- package/pushwoosh-react-native-plugin.podspec +2 -2
package/README.md
CHANGED
|
@@ -1,72 +1,340 @@
|
|
|
1
|
-
|
|
2
|
-
===================================================
|
|
1
|
+
<h1 align="center">Pushwoosh React Native Plugin</h1>
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases"><img src="https://img.shields.io/github/release/Pushwoosh/pushwoosh-react-native-plugin.svg?style=flat-square" alt="GitHub release"></a>
|
|
5
|
+
<a href="https://www.npmjs.com/package/pushwoosh-react-native-plugin"><img src="https://img.shields.io/npm/v/pushwoosh-react-native-plugin.svg?style=flat-square" alt="npm"></a>
|
|
6
|
+
<a href="https://www.npmjs.com/package/pushwoosh-react-native-plugin"><img src="https://img.shields.io/npm/l/pushwoosh-react-native-plugin.svg?style=flat-square" alt="license"></a>
|
|
7
|
+
</p>
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
Cross-platform push notifications, In-App messaging, and more for React Native applications.
|
|
11
|
+
</p>
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
| ----------------------------------------------------------- | ------------------------------- | -------------------------------------------------------------------- |
|
|
13
|
+
## Table of Contents
|
|
12
14
|
|
|
15
|
+
- [Documentation](#documentation)
|
|
16
|
+
- [Features](#features)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [AI-Assisted Integration](#ai-assisted-integration)
|
|
19
|
+
- [Quick Start](#quick-start)
|
|
20
|
+
- [API Reference](#api-reference)
|
|
21
|
+
- [Support](#support)
|
|
22
|
+
- [License](#license)
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
- [Integration Guide](https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin) — step-by-step setup
|
|
27
|
+
- [API Reference](docs/README.md) — full API documentation
|
|
28
|
+
- [Sample Project](https://github.com/Pushwoosh/pushwoosh-react-native-sample) — ready-to-run demo app
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **Push Notifications** — register, receive, and handle push notifications on iOS and Android
|
|
33
|
+
- **In-App Messages** — trigger and display in-app messages based on events
|
|
34
|
+
- **Tags & Segmentation** — set and get user tags for targeted messaging
|
|
35
|
+
- **User Identification** — associate devices with user IDs for cross-device tracking
|
|
36
|
+
- **Message Inbox** — built-in UI for message inbox with customization options
|
|
37
|
+
- **Badge Management** — set, get, and increment app icon badge numbers
|
|
38
|
+
- **Local Notifications** — schedule and manage local notifications
|
|
39
|
+
- **Rich Media** — modal and legacy Rich Media presentation styles
|
|
40
|
+
- **Huawei Push** — HMS push notification support
|
|
41
|
+
- **Multi-channel** — email, SMS, and WhatsApp registration
|
|
42
|
+
- **TypeScript Support** — full TypeScript definitions included
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
16
47
|
npm install pushwoosh-react-native-plugin --save
|
|
17
|
-
react-native link pushwoosh-react-native-plugin
|
|
18
48
|
```
|
|
19
49
|
|
|
20
|
-
|
|
50
|
+
### iOS Setup
|
|
21
51
|
|
|
52
|
+
```bash
|
|
53
|
+
cd ios && pod install
|
|
22
54
|
```
|
|
23
|
-
|
|
55
|
+
|
|
56
|
+
### Android Setup
|
|
57
|
+
|
|
58
|
+
Add to your project's `build.gradle`:
|
|
59
|
+
|
|
60
|
+
```groovy
|
|
24
61
|
buildscript {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
62
|
+
dependencies {
|
|
63
|
+
classpath 'com.google.gms:google-services:4.3.15'
|
|
64
|
+
}
|
|
28
65
|
}
|
|
66
|
+
```
|
|
29
67
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
plugin
|
|
33
|
-
|
|
68
|
+
## AI-Assisted Integration
|
|
69
|
+
|
|
70
|
+
Integrate the Pushwoosh React Native plugin using AI coding assistants (Claude Code, Cursor, GitHub Copilot, etc.).
|
|
71
|
+
|
|
72
|
+
> **Requirement:** Your AI assistant must have access to [Context7](https://context7.com/) MCP server or web search capabilities.
|
|
73
|
+
|
|
74
|
+
### Quick Start Prompts
|
|
75
|
+
|
|
76
|
+
Choose the prompt that matches your task:
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
#### 1. Basic Plugin Integration
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
Integrate Pushwoosh React Native plugin into my React Native project.
|
|
84
|
+
|
|
85
|
+
Requirements:
|
|
86
|
+
- Install pushwoosh-react-native-plugin via npm
|
|
87
|
+
- Initialize Pushwoosh with my App ID in the app entry point
|
|
88
|
+
- Register for push notifications and handle pushOpened events via DeviceEventEmitter
|
|
89
|
+
|
|
90
|
+
Use Context7 MCP to fetch Pushwoosh React Native plugin documentation.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
#### 2. Tags and User Segmentation
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
Show me how to use Pushwoosh tags in a React Native app for user segmentation.
|
|
99
|
+
I need to set tags, get tags, and set user ID for cross-device tracking.
|
|
100
|
+
|
|
101
|
+
Use Context7 MCP to fetch Pushwoosh React Native plugin documentation for setTags and getTags.
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
#### 3. Message Inbox Integration
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Integrate Pushwoosh Message Inbox into my React Native app. Show me how to:
|
|
110
|
+
- Display the inbox UI with custom styling
|
|
111
|
+
- Load messages programmatically
|
|
112
|
+
- Track unread message count
|
|
113
|
+
|
|
114
|
+
Use Context7 MCP to fetch Pushwoosh React Native plugin documentation for presentInboxUI.
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Quick Start
|
|
120
|
+
|
|
121
|
+
### 1. Initialize the Plugin
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
125
|
+
import { DeviceEventEmitter } from 'react-native';
|
|
126
|
+
|
|
127
|
+
// Listen for push notification events
|
|
128
|
+
DeviceEventEmitter.addListener('pushOpened', (e) => {
|
|
129
|
+
console.log("Push opened: " + JSON.stringify(e));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Initialize Pushwoosh
|
|
133
|
+
Pushwoosh.init({
|
|
134
|
+
pw_appid: "YOUR_PUSHWOOSH_APP_ID",
|
|
135
|
+
project_number: "YOUR_FCM_SENDER_ID"
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Register for push notifications
|
|
139
|
+
Pushwoosh.register(
|
|
140
|
+
(token) => {
|
|
141
|
+
console.log("Registered with push token: " + token);
|
|
142
|
+
},
|
|
143
|
+
(error) => {
|
|
144
|
+
console.error("Failed to register: " + error);
|
|
145
|
+
}
|
|
146
|
+
);
|
|
34
147
|
```
|
|
35
148
|
|
|
36
|
-
###
|
|
149
|
+
### 2. Set User Tags
|
|
37
150
|
|
|
38
|
-
```
|
|
151
|
+
```javascript
|
|
39
152
|
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
40
153
|
|
|
41
|
-
Pushwoosh.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
154
|
+
Pushwoosh.setTags(
|
|
155
|
+
{ username: "john_doe", age: 25, interests: ["sports", "tech"] },
|
|
156
|
+
() => console.log("Tags set successfully"),
|
|
157
|
+
(error) => console.error("Failed to set tags: " + error)
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
Pushwoosh.getTags(
|
|
161
|
+
(tags) => console.log("Tags: " + JSON.stringify(tags)),
|
|
162
|
+
(error) => console.error("Get tags error: " + error)
|
|
163
|
+
);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3. Post Events for In-App Messages
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
170
|
+
|
|
171
|
+
Pushwoosh.setUserId("user_12345");
|
|
172
|
+
Pushwoosh.postEvent("purchase_complete", {
|
|
173
|
+
productName: "Premium Plan",
|
|
174
|
+
amount: "9.99"
|
|
44
175
|
});
|
|
45
|
-
Pushwoosh.register();
|
|
46
176
|
```
|
|
47
177
|
|
|
48
|
-
|
|
178
|
+
### 4. Message Inbox
|
|
49
179
|
|
|
50
|
-
```
|
|
180
|
+
```javascript
|
|
51
181
|
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
182
|
+
import { processColor, Image } from 'react-native';
|
|
183
|
+
|
|
184
|
+
// Open inbox UI with custom styling
|
|
185
|
+
Pushwoosh.presentInboxUI({
|
|
186
|
+
dateFormat: "dd.MM.yyyy",
|
|
187
|
+
accentColor: processColor('#3498db'),
|
|
188
|
+
backgroundColor: processColor('#ffffff'),
|
|
189
|
+
titleColor: processColor('#333333'),
|
|
190
|
+
descriptionColor: processColor('#666666'),
|
|
191
|
+
listEmptyMessage: "No messages yet"
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Or load messages programmatically
|
|
195
|
+
Pushwoosh.loadMessages(
|
|
196
|
+
(messages) => {
|
|
197
|
+
messages.forEach((msg) => {
|
|
198
|
+
console.log(msg.title + ": " + msg.message);
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
(error) => console.error("Failed to load: " + error)
|
|
202
|
+
);
|
|
52
203
|
|
|
53
|
-
Pushwoosh.
|
|
54
|
-
"
|
|
55
|
-
"project_number" : "YOUR_GCM_PROJECT_NUMBER",
|
|
56
|
-
"pw_notification_handling" : "CUSTOM"
|
|
204
|
+
Pushwoosh.unreadMessagesCount((count) => {
|
|
205
|
+
console.log("Unread messages: " + count);
|
|
57
206
|
});
|
|
58
|
-
Pushwoosh.register();
|
|
59
207
|
```
|
|
60
208
|
|
|
61
|
-
|
|
209
|
+
### 5. Multi-channel Communication
|
|
62
210
|
|
|
63
|
-
```
|
|
211
|
+
```javascript
|
|
64
212
|
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
65
213
|
|
|
66
|
-
Pushwoosh.
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
214
|
+
Pushwoosh.setEmails(
|
|
215
|
+
["user@example.com"],
|
|
216
|
+
() => console.log("Email set"),
|
|
217
|
+
(error) => console.error(error)
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
Pushwoosh.registerSMSNumber("+1234567890");
|
|
221
|
+
Pushwoosh.registerWhatsappNumber("+1234567890");
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 6. Custom Notification Handling (iOS)
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
228
|
+
|
|
229
|
+
Pushwoosh.init({
|
|
230
|
+
pw_appid: "YOUR_PUSHWOOSH_APP_ID",
|
|
231
|
+
project_number: "YOUR_FCM_SENDER_ID",
|
|
232
|
+
pw_notification_handling: "CUSTOM"
|
|
70
233
|
});
|
|
71
|
-
Pushwoosh.register();
|
|
72
234
|
```
|
|
235
|
+
|
|
236
|
+
## API Reference
|
|
237
|
+
|
|
238
|
+
### Initialization & Registration
|
|
239
|
+
|
|
240
|
+
| Method | Description |
|
|
241
|
+
|--------|-------------|
|
|
242
|
+
| `init(config, success?, fail?)` | Initialize the plugin. Call on every app launch |
|
|
243
|
+
| `register(success?, fail?)` | Register for push notifications |
|
|
244
|
+
| `unregister(success?, fail?)` | Unregister from push notifications |
|
|
245
|
+
| `getPushToken(success)` | Get the push token |
|
|
246
|
+
| `getHwid(success)` | Get Pushwoosh Hardware ID |
|
|
247
|
+
| `getUserId(success)` | Get current user ID |
|
|
248
|
+
|
|
249
|
+
### Tags & User Data
|
|
250
|
+
|
|
251
|
+
| Method | Description |
|
|
252
|
+
|--------|-------------|
|
|
253
|
+
| `setTags(tags, success?, fail?)` | Set device tags |
|
|
254
|
+
| `getTags(success, fail?)` | Get device tags |
|
|
255
|
+
| `setUserId(userId, success?, fail?)` | Set user identifier for cross-device tracking |
|
|
256
|
+
| `setLanguage(language)` | Set custom language for localized pushes |
|
|
257
|
+
| `setEmails(emails, success?, fail?)` | Register emails for the user |
|
|
258
|
+
| `setUserEmails(userId, emails, success?, fail?)` | Set user ID and register emails |
|
|
259
|
+
| `registerSMSNumber(phoneNumber)` | Register SMS number (E.164 format) |
|
|
260
|
+
| `registerWhatsappNumber(phoneNumber)` | Register WhatsApp number (E.164 format) |
|
|
261
|
+
|
|
262
|
+
### Notifications
|
|
263
|
+
|
|
264
|
+
| Method | Description |
|
|
265
|
+
|--------|-------------|
|
|
266
|
+
| `createLocalNotification(config)` | Schedule a local notification |
|
|
267
|
+
| `clearLocalNotification()` | Clear all pending local notifications |
|
|
268
|
+
| `clearNotificationCenter()` | Clear all notifications from notification center |
|
|
269
|
+
|
|
270
|
+
### Badge Management
|
|
271
|
+
|
|
272
|
+
| Method | Description |
|
|
273
|
+
|--------|-------------|
|
|
274
|
+
| `setApplicationIconBadgeNumber(badge)` | Set badge number |
|
|
275
|
+
| `getApplicationIconBadgeNumber(callback)` | Get current badge number |
|
|
276
|
+
| `addToApplicationIconBadgeNumber(badge)` | Increment/decrement badge |
|
|
277
|
+
|
|
278
|
+
### In-App Messages & Events
|
|
279
|
+
|
|
280
|
+
| Method | Description |
|
|
281
|
+
|--------|-------------|
|
|
282
|
+
| `postEvent(event, attributes?)` | Post event to trigger In-App Messages |
|
|
283
|
+
| `setRichMediaType(type)` | Set Rich Media style (MODAL or LEGACY) |
|
|
284
|
+
| `getRichMediaType(callback)` | Get current Rich Media style |
|
|
285
|
+
|
|
286
|
+
### Message Inbox
|
|
287
|
+
|
|
288
|
+
| Method | Description |
|
|
289
|
+
|--------|-------------|
|
|
290
|
+
| `presentInboxUI(style?)` | Open inbox UI with optional style customization |
|
|
291
|
+
| `loadMessages(success, fail?)` | Load inbox messages programmatically |
|
|
292
|
+
| `unreadMessagesCount(callback)` | Get unread message count |
|
|
293
|
+
| `messagesCount(callback)` | Get total message count |
|
|
294
|
+
| `messagesWithNoActionPerformedCount(callback)` | Get messages with no action count |
|
|
295
|
+
| `readMessage(id)` | Mark message as read |
|
|
296
|
+
| `readMessages(ids)` | Mark multiple messages as read |
|
|
297
|
+
| `deleteMessage(id)` | Delete a message |
|
|
298
|
+
| `deleteMessages(ids)` | Delete multiple messages |
|
|
299
|
+
| `performAction(id)` | Perform the action associated with a message |
|
|
300
|
+
|
|
301
|
+
### Android-specific
|
|
302
|
+
|
|
303
|
+
| Method | Description |
|
|
304
|
+
|--------|-------------|
|
|
305
|
+
| `setMultiNotificationMode(on)` | Allow multiple notifications in notification center |
|
|
306
|
+
| `setLightScreenOnNotification(on)` | Turn screen on when notification arrives |
|
|
307
|
+
| `setEnableLED(on)` | Enable LED blinking on notification |
|
|
308
|
+
| `setColorLED(color)` | Set LED color (ARGB integer) |
|
|
309
|
+
| `setSoundType(type)` | Set sound type (0=default, 1=none, 2=always) |
|
|
310
|
+
| `setVibrateType(type)` | Set vibration type (0=default, 1=none, 2=always) |
|
|
311
|
+
| `setNotificationIconBackgroundColor(color)` | Set notification icon background color |
|
|
312
|
+
| `enableHuaweiPushNotifications()` | Enable Huawei HMS push support |
|
|
313
|
+
|
|
314
|
+
### Communication Control
|
|
315
|
+
|
|
316
|
+
| Method | Description |
|
|
317
|
+
|--------|-------------|
|
|
318
|
+
| `setCommunicationEnabled(enable, success?, fail?)` | Enable/disable all Pushwoosh communication |
|
|
319
|
+
| `isCommunicationEnabled(success)` | Check if communication is enabled |
|
|
320
|
+
|
|
321
|
+
### Events (DeviceEventEmitter)
|
|
322
|
+
|
|
323
|
+
| Event | Description |
|
|
324
|
+
|-------|-------------|
|
|
325
|
+
| `pushOpened` | Fired when a notification is opened by the user |
|
|
326
|
+
| `pushReceived` | Fired when a notification is received |
|
|
327
|
+
|
|
328
|
+
## Support
|
|
329
|
+
|
|
330
|
+
- [Documentation](https://docs.pushwoosh.com/)
|
|
331
|
+
- [Support Portal](https://support.pushwoosh.com/)
|
|
332
|
+
- [Report Issues](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/issues)
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
Pushwoosh React Native Plugin is available under the MIT license. See [LICENSE](LICENSE) for details.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
Made with ❤️ by [Pushwoosh](https://www.pushwoosh.com/)
|
package/index.js
CHANGED
|
@@ -1,5 +1,187 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Pushwoosh React Native Plugin - Integration Guide
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Pushwoosh is a customer engagement platform for push notifications, in-app messages,
|
|
8
|
+
* emails, SMS, and WhatsApp. This React Native plugin wraps native iOS and Android
|
|
9
|
+
* Pushwoosh SDKs and provides a JavaScript bridge for hybrid mobile applications.
|
|
10
|
+
*
|
|
11
|
+
* @section Installation
|
|
12
|
+
*
|
|
13
|
+
* ```bash
|
|
14
|
+
* npm install pushwoosh-react-native-plugin --save
|
|
15
|
+
* cd ios && pod install
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @section Quick Start
|
|
19
|
+
*
|
|
20
|
+
* Step 1: Initialize the plugin and register for push notifications
|
|
21
|
+
*
|
|
22
|
+
* ```javascript
|
|
23
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
24
|
+
* import { DeviceEventEmitter } from 'react-native';
|
|
25
|
+
*
|
|
26
|
+
* // Listen for push notification events
|
|
27
|
+
* DeviceEventEmitter.addListener('pushOpened', (e) => {
|
|
28
|
+
* console.log("Push opened: " + JSON.stringify(e));
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Initialize Pushwoosh
|
|
32
|
+
* Pushwoosh.init({
|
|
33
|
+
* pw_appid: "XXXXX-XXXXX",
|
|
34
|
+
* project_number: "YOUR_FCM_SENDER_ID"
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Register for push notifications
|
|
38
|
+
* Pushwoosh.register(
|
|
39
|
+
* (token) => {
|
|
40
|
+
* console.log("Registered with push token: " + token);
|
|
41
|
+
* },
|
|
42
|
+
* (error) => {
|
|
43
|
+
* console.error("Failed to register: " + error);
|
|
44
|
+
* }
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @section Common Use Cases
|
|
49
|
+
*
|
|
50
|
+
* User identification and cross-device tracking:
|
|
51
|
+
*
|
|
52
|
+
* ```javascript
|
|
53
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
54
|
+
*
|
|
55
|
+
* // After user login
|
|
56
|
+
* Pushwoosh.setUserId("user_12345");
|
|
57
|
+
* Pushwoosh.setEmails(["user@example.com"]);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* User segmentation with tags:
|
|
61
|
+
*
|
|
62
|
+
* ```javascript
|
|
63
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
64
|
+
*
|
|
65
|
+
* Pushwoosh.setTags(
|
|
66
|
+
* { subscription: "premium", age: 25, interests: ["sports", "music"] },
|
|
67
|
+
* () => console.log("Tags set successfully"),
|
|
68
|
+
* (error) => console.error("Failed to set tags: " + error)
|
|
69
|
+
* );
|
|
70
|
+
*
|
|
71
|
+
* Pushwoosh.getTags(
|
|
72
|
+
* (tags) => console.log("Tags: " + JSON.stringify(tags)),
|
|
73
|
+
* (error) => console.error("Get tags error: " + error)
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Trigger In-App Messages with events:
|
|
78
|
+
*
|
|
79
|
+
* ```javascript
|
|
80
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
81
|
+
*
|
|
82
|
+
* Pushwoosh.setUserId("user_12345");
|
|
83
|
+
* Pushwoosh.postEvent("purchase_complete", {
|
|
84
|
+
* productName: "Premium Plan",
|
|
85
|
+
* amount: "9.99"
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* Schedule a local notification:
|
|
90
|
+
*
|
|
91
|
+
* ```javascript
|
|
92
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
93
|
+
*
|
|
94
|
+
* Pushwoosh.createLocalNotification({
|
|
95
|
+
* msg: "Your order is ready!",
|
|
96
|
+
* seconds: 60,
|
|
97
|
+
* userData: { orderId: "12345" }
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* Message Inbox with custom styling:
|
|
102
|
+
*
|
|
103
|
+
* ```javascript
|
|
104
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
105
|
+
* import { processColor } from 'react-native';
|
|
106
|
+
*
|
|
107
|
+
* Pushwoosh.presentInboxUI({
|
|
108
|
+
* dateFormat: "dd.MM.yyyy",
|
|
109
|
+
* accentColor: processColor('#3498db'),
|
|
110
|
+
* backgroundColor: processColor('#ffffff'),
|
|
111
|
+
* titleColor: processColor('#333333'),
|
|
112
|
+
* descriptionColor: processColor('#666666'),
|
|
113
|
+
* listEmptyMessage: "No messages yet"
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Or load messages programmatically
|
|
117
|
+
* Pushwoosh.loadMessages(
|
|
118
|
+
* (messages) => {
|
|
119
|
+
* messages.forEach((msg) => {
|
|
120
|
+
* console.log(msg.title + ": " + msg.message);
|
|
121
|
+
* });
|
|
122
|
+
* },
|
|
123
|
+
* (error) => console.error("Failed to load: " + error)
|
|
124
|
+
* );
|
|
125
|
+
*
|
|
126
|
+
* Pushwoosh.unreadMessagesCount((count) => {
|
|
127
|
+
* console.log("Unread messages: " + count);
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Multi-channel communication:
|
|
132
|
+
*
|
|
133
|
+
* ```javascript
|
|
134
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
135
|
+
*
|
|
136
|
+
* Pushwoosh.setEmails(["user@example.com"]);
|
|
137
|
+
* Pushwoosh.registerSMSNumber("+1234567890");
|
|
138
|
+
* Pushwoosh.registerWhatsappNumber("+1234567890");
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* Enable/disable Pushwoosh communication (e.g. for GDPR):
|
|
142
|
+
*
|
|
143
|
+
* ```javascript
|
|
144
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
145
|
+
*
|
|
146
|
+
* // User opted out
|
|
147
|
+
* Pushwoosh.setCommunicationEnabled(false);
|
|
148
|
+
*
|
|
149
|
+
* // User opted in
|
|
150
|
+
* Pushwoosh.setCommunicationEnabled(true);
|
|
151
|
+
*
|
|
152
|
+
* // Check current status
|
|
153
|
+
* Pushwoosh.isCommunicationEnabled((enabled) => {
|
|
154
|
+
* console.log("Communication enabled: " + enabled);
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* Custom notification handling on iOS:
|
|
159
|
+
*
|
|
160
|
+
* ```javascript
|
|
161
|
+
* import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
162
|
+
*
|
|
163
|
+
* Pushwoosh.init({
|
|
164
|
+
* pw_appid: "XXXXX-XXXXX",
|
|
165
|
+
* project_number: "YOUR_FCM_SENDER_ID",
|
|
166
|
+
* pw_notification_handling: "CUSTOM"
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @section Configuration Parameters
|
|
171
|
+
*
|
|
172
|
+
* - pw_appid (required) - Pushwoosh Application ID from Control Panel
|
|
173
|
+
* - project_number (required for Android) - FCM Sender ID
|
|
174
|
+
* - pw_notification_handling (optional, iOS) - Set to "CUSTOM" for custom notification handling
|
|
175
|
+
* - reverse_proxy_url (optional) - URL to reverse proxy for Pushwoosh server communication
|
|
176
|
+
*
|
|
177
|
+
* @section Events (DeviceEventEmitter)
|
|
178
|
+
*
|
|
179
|
+
* - "pushOpened" - Fired when a notification is opened by the user.
|
|
180
|
+
* - "pushReceived" - Fired when a notification is received.
|
|
181
|
+
*
|
|
182
|
+
* @module pushwoosh-react-native-plugin
|
|
183
|
+
*/
|
|
184
|
+
|
|
3
185
|
import { NativeModules } from 'react-native';
|
|
4
186
|
|
|
5
187
|
const PushwooshModule = NativeModules.Pushwoosh;
|
|
@@ -20,29 +202,12 @@ const RichMediaStyle = {
|
|
|
20
202
|
LEGACY: 1
|
|
21
203
|
};
|
|
22
204
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// console.warn("pushOpened: " + JSON.stringify(e));
|
|
30
|
-
// alert(JSON.stringify(e));
|
|
31
|
-
//});
|
|
32
|
-
//
|
|
33
|
-
//const Pushwoosh = require('pushwoosh-react-native-plugin');
|
|
34
|
-
//
|
|
35
|
-
//Pushwoosh.init({ "pw_appid" : "XXXX-XXXX", "project_number" : "XXXXXXXXXXXXX", "reverse_proxy_url" : "your_url_proxy" });
|
|
36
|
-
//
|
|
37
|
-
//Pushwoosh.register(
|
|
38
|
-
// (token) => {
|
|
39
|
-
// console.warn("Registered for pushes: " + token);
|
|
40
|
-
// },
|
|
41
|
-
// (error) => {
|
|
42
|
-
// console.warn("Failed to register: " + error);
|
|
43
|
-
// }
|
|
44
|
-
//);
|
|
45
|
-
//(end)
|
|
205
|
+
/**
|
|
206
|
+
* PushNotification class provides the JavaScript API for interacting with the Pushwoosh SDK.
|
|
207
|
+
* Import it via: `import Pushwoosh from 'pushwoosh-react-native-plugin';`
|
|
208
|
+
*
|
|
209
|
+
* @class PushNotification
|
|
210
|
+
*/
|
|
46
211
|
class PushNotification {
|
|
47
212
|
|
|
48
213
|
//Function: init
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = "pushwoosh-react-native-plugin"
|
|
3
|
-
s.version = "6.1.
|
|
3
|
+
s.version = "6.1.53"
|
|
4
4
|
s.summary = "React Native Pushwoosh Push Notifications module"
|
|
5
5
|
s.requires_arc = true
|
|
6
6
|
s.author = 'Pushwoosh'
|
|
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.static_framework = true
|
|
16
16
|
|
|
17
17
|
s.dependency 'React'
|
|
18
|
-
s.dependency 'PushwooshXCFramework', '7.0.
|
|
18
|
+
s.dependency 'PushwooshXCFramework', '7.0.22'
|
|
19
19
|
s.dependency 'PushwooshInboxUIXCFramework'
|
|
20
20
|
end
|