pushwoosh-react-native-plugin 2.0.0 → 2.2.17

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.
Files changed (66) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +135 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.yml +31 -0
  3. package/.github/ISSUE_TEMPLATE/question.yml +28 -0
  4. package/InlineInApp.js +71 -0
  5. package/README.md +35 -85
  6. package/docs/README.md +230 -11
  7. package/index.d.ts +91 -0
  8. package/index.js +265 -24
  9. package/package.json +12 -1
  10. package/pushwoosh-react-native-plugin.podspec +20 -0
  11. package/react-native.config.js +9 -0
  12. package/scripts/add_inbox_ios_resources.js +42 -0
  13. package/src/android/build.gradle +40 -10
  14. package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  15. package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  16. package/src/android/gradlew +160 -0
  17. package/src/android/gradlew.bat +90 -0
  18. package/src/android/src/main/AndroidManifest.xml +19 -54
  19. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/ConversionUtil.java +214 -148
  20. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/CustomFirebaseMessagingService.java +29 -0
  21. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/EventDispatcher.java +7 -6
  22. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InboxUiStyleManager.java +162 -0
  23. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InlineInAppManager.java +48 -0
  24. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshNotificationServiceExtension.java +44 -0
  25. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPackage.java +4 -2
  26. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +606 -393
  27. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/RCTInlineInAppView.java +75 -0
  28. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/internal/ReactNativePluginProvider.java +15 -0
  29. package/src/ios/PWAppDelegate.h +20 -0
  30. package/src/ios/PWGDPRManager.h +46 -0
  31. package/src/ios/PWIInboxStyle.h +122 -0
  32. package/src/ios/PWIInboxUI.h +39 -0
  33. package/src/ios/PWInAppManager.h +176 -0
  34. package/src/ios/PWInbox.h +147 -0
  35. package/src/ios/PWInlineInAppView.h +26 -0
  36. package/src/ios/PWLog.h +23 -0
  37. package/src/ios/PWMessaging.h +20 -0
  38. package/src/ios/PWNotificationExtensionManager.h +46 -0
  39. package/src/ios/PWRichMediaManager.h +123 -0
  40. package/src/ios/PWRichMediaStyle.h +122 -0
  41. package/src/ios/PushNotificationManager.h +234 -111
  42. package/src/ios/Pushwoosh.h +623 -0
  43. package/src/ios/PushwooshInboxBundle.bundle/Info.plist +0 -0
  44. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxAttachmentViewController.nib +0 -0
  45. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxMessageViewCell.nib +0 -0
  46. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxViewController.nib +0 -0
  47. package/src/ios/PushwooshInboxBundle.bundle/errorMessage@2x.png +0 -0
  48. package/src/ios/PushwooshInboxBundle.bundle/inbox_icon.png +0 -0
  49. package/src/ios/PushwooshInboxBundle.bundle/noMessage@2x.png +0 -0
  50. package/src/ios/PushwooshInboxBundle.bundle/unread.png +0 -0
  51. package/src/ios/PushwooshInboxUI.h +19 -0
  52. package/src/ios/PushwooshPlugin/PWEventDispatcher.h +1 -1
  53. package/src/ios/PushwooshPlugin/PWInlineInAppManager.h +17 -0
  54. package/src/ios/PushwooshPlugin/PWInlineInAppManager.m +54 -0
  55. package/src/ios/PushwooshPlugin/Pushwoosh.h +18 -3
  56. package/src/ios/PushwooshPlugin/Pushwoosh.m +532 -98
  57. package/src/ios/PushwooshPlugin.xcodeproj/project.pbxproj +27 -6
  58. package/src/ios/libPushwoosh.a +0 -0
  59. package/src/ios/libPushwooshInboxUI.a +0 -0
  60. package/.npmignore +0 -3
  61. package/src/android/.npmignore +0 -1
  62. package/src/android/pushwooshplugin.iml +0 -150
  63. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/NotificationReceiver.java +0 -42
  64. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PostEventActivity.java +0 -45
  65. package/src/ios/Pushwoosh.a +0 -0
  66. package/src/ios/PushwooshPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
package/docs/README.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  # Pushwoosh React Native Module #
2
3
 
3
4
  Provides module for React Native to receive and handle push notifications for iOS and Android.
@@ -17,13 +18,17 @@ Pushwoosh.register(
17
18
  console.warn("Failed to register for push notifications: " + error);
18
19
  }
19
20
  );
20
- ```
21
21
 
22
- <style>
23
- td {
24
- background-color:#FFFFFF;
25
- }
26
- </style>
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
+ ```
27
32
 
28
33
  <br>
29
34
  <h3>Summary</h3>
@@ -34,14 +39,34 @@ td {
34
39
  <th align="left" colspan="2"><strong>Functions</strong></th>
35
40
  </tr>
36
41
  <tr class="even"><td><a href="#init">init(config, success, fail)</a></td></tr>
37
- <tr class="odd"><td><a href="#register">register(success, fail)</a></td></tr>
42
+ <tr class="even"><td><a href="#register">register(success, fail)</a></td></tr>
38
43
  <tr class="even"><td><a href="#unregister">unregister(success, fail)</a></td></tr>
39
- <tr class="odd"><td><a href="#settags">setTags(tags, success, fail)</a></td></tr>
44
+ <tr class="even"><td><a href="#settags">setTags(tags, success, fail)</a></td></tr>
40
45
  <tr class="even"><td><a href="#gettags">getTags(success, fail)</a></td></tr>
41
- <tr class="odd"><td><a href="#getpushtoken">getPushToken(success)</a></td></tr>
46
+ <tr class="even"><td><a href="#getpushtoken">getPushToken(success)</a></td></tr>
42
47
  <tr class="even"><td><a href="#gethwid">getHwid(success)</a></td></tr>
43
- <tr class="even"><td><a href="#setuserid">setUserId(userId)</a></td></tr>
48
+ <tr class="even"><td><a href="#setuserid">setUserId(userId, success, fail)</a></td></tr>
44
49
  <tr class="even"><td><a href="#postevent">postEvent(event, attributes)</a></td></tr>
50
+ <tr class="even"><td><a href="#setapplicationiconbadgenumber">setApplicationIconBadgeNumber(badgeNumber)</a></td></tr>
51
+ <tr class="even"><td><a href="#getapplicationiconbadgenumber">getApplicationIconBadgeNumber(callback)</a></td></tr>
52
+ <tr class="even"><td><a href="#addtoapplicationiconbadgenumber">addToApplicationIconBadgeNumber(badgeNumber)</a></td></tr>
53
+ <tr class="even"><td><a href="#setmultinotificationmode">setMultiNotificationMode(on)</a></td></tr>
54
+ <tr class="even"><td><a href="#setlightscreenonnotification">setLightScreenOnNotification(on)</a></td></tr>
55
+ <tr class="even"><td><a href="#setenableled">setEnableLED(on)</a></td></tr>
56
+ <tr class="even"><td><a href="#setcolorled">setColorLED(color)</a></td></tr>
57
+ <tr class="even"><td><a href="#setsoundtype">setSoundType(type)</a></td></tr>
58
+ <tr class="even"><td><a href="#setvibratetype">setVibrateType(type)</a></td></tr>
59
+ <tr class="even"><td><a href="#presentinboxui">presentInboxUI()</a></td></tr>
60
+ <tr class="even"><td><a href="#showgdprconsentui">showGDPRConsentUI()</a></td></tr>
61
+ <tr class="even"><td><a href="#showgdprdeletionui">showGDPRDeletionUI()</a></td></tr>
62
+ <tr class="even"><td><a href="#setcommunicationenabled">setCommunicationEnabled()</a></td></tr>
63
+ <tr class="even"><td><a href="#removealldevicedata">removeAllDeviceData()</a></td></tr>
64
+ <tr class="even"><td><a href="#enableHuaweiPushNotifications">enableHuaweiPushNotifications()</a></td></tr>
65
+ <tr>
66
+ <th align="left" colspan="2"><strong>Events</strong></th>
67
+ </tr>
68
+ <tr class="even"><td><a href="#pushopened">pushOpened</a></td></tr>
69
+ <tr class="even"><td><a href="#pushreceived">pushReceived</a></td></tr>
45
70
  </tbody>
46
71
  </table>
47
72
  <hr />
@@ -68,6 +93,8 @@ Initializes Pushwoosh module with application id and google project number.
68
93
  <tr class="even"><td>object</td><td><b>config</b></td><td>Pushwoosh initialization config.</td></tr>
69
94
  <tr class="even"><td>string</td><td><b>config.pw_appid</b></td><td>Pushwoosh application id.</td></tr>
70
95
  <tr class="even"><td>string</td><td><b>config.project_number</b></td><td>GCM project number (for Android push notifications).</td></tr>
96
+ <tr class="even"><td>string</td><td><b>config.reverse_proxy_url</b></td><td>(optional) Url to your reverse proxy.</td></tr>
97
+ <tr class="even"><td>string</td><td><b>config.pw_notification_handling</b></td><td>(optional) To use custom notification handling on iOS specify the parameter "pw_notification_handling" to "CUSTOM".</td></tr>
71
98
  <tr class="even"><td>function</td><td><b>success</b></td><td>(optional) initialization success callback.</td></tr>
72
99
  <tr class="even"><td>function</td><td><b>fail</b></td><td>(optional) initialization failure callback.</td></tr>
73
100
  </tbody>
@@ -244,7 +271,7 @@ Returns Pushwoosh HWID used for communications with Pushwoosh API.
244
271
  ### setUserId
245
272
 
246
273
  ```js
247
- setUserId(userId)
274
+ setUserId(userId, success, fail)
248
275
  ```
249
276
 
250
277
  Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
@@ -261,6 +288,8 @@ This allows data and events to be matched across multiple user devices.
261
288
  <th align="left" colspan="3"><strong>Parameters</strong></th>
262
289
  </tr>
263
290
  <tr class="even"><td>string</td><td><b>userId</b></td><td>Identifier of currently logged in user</td></tr>
291
+ <tr class="even"><td>function</td><td><b>success</b></td><td>(optional) method success callback.</td></tr>
292
+ <tr class="even"><td>function</td><td><b>fail</b></td><td>(optional) method failure callback.</td></tr>
264
293
  </tbody>
265
294
  </table>
266
295
 
@@ -294,3 +323,193 @@ Example:
294
323
  ```js
295
324
  Pushwoosh.postEvent("buttonPressed", { "buttonNumber" : "4", "buttonLabel" : "Banner" })
296
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 <a href="https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/android-push-notifications/huawei-integration/huawei-in-react-native">integration guide</a>.
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.
package/index.d.ts ADDED
@@ -0,0 +1,91 @@
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<string, string | number | string[] | number[] | boolean>
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
+ setUserId(userId: string, success?: ()=> void, fail?: (error: Error) => void): void;
49
+ postEvent(event: string, attributes?: Record<string, string>): void;
50
+ enableHuaweiPushNotifications(): void;
51
+
52
+ //badge methods
53
+ setApplicationIconBadgeNumber(badgeNumber: number): void;
54
+ getApplicationIconBadgeNumber(callback: (badge: number) => void): void;
55
+ addToApplicationIconBadgeNumber(badgeNumber: number): void;
56
+
57
+ //Notification appearance
58
+ setMultiNotificationMode(on: boolean): void;
59
+ setLightScreenOnNotification(on: boolean): void;
60
+ setEnableLED(on: boolean): void;
61
+ setColorLED(color: number): void;
62
+ setSoundType(type: number): void;
63
+ setVibrateType(type: number): void;
64
+ setNotificationIconBackgroundColor(color: string): void;
65
+ setLanguage(language: string): void;
66
+
67
+ //Inbox API
68
+ presentInboxUI(style?: Object): void;
69
+ messagesWithNoActionPerformedCount(callback: (result: number) => void): void;
70
+ unreadMessagesCount(callback: (result: number) => void): void;
71
+ messagesCount(callback: (result: number) => void): void;
72
+ loadMessages(success: (notifications: InboxNotification[]) => void, fail?: (error: Error) => void): void;
73
+ readMessage(id: string): void;
74
+ readMessages(ids: string[]): void;
75
+ deleteMessage(id: string): void;
76
+ deleteMessages(ids: string[]): void;
77
+ performAction(id: string): void;
78
+
79
+ //GDPR methods
80
+ showGDPRConsentUI(): void;
81
+ showGDPRDeletionUI(): void;
82
+ isDeviceDataRemoved(success: (isRemoved: boolean) => void): void;
83
+ isCommunicationEnabled(success: (isEnabled: boolean)=> void): void;
84
+ isAvailableGDPR(success: (isAvailable: boolean) => void): void;
85
+ setCommunicationEnabled(enabled: boolean, success?: () => void, fail?: (error: Error) => void): void;
86
+ removeAllDeviceData(success?: () => void, fail?: (error: Error) => void): void;
87
+ }
88
+
89
+ const Pushwoosh: Pushwoosh;
90
+ export = Pushwoosh;
91
+ }