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
@@ -0,0 +1,162 @@
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
+ }
@@ -0,0 +1,48 @@
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<RCTInlineInAppView> {
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
+ }
@@ -0,0 +1,44 @@
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", false) || ai.metaData.getBoolean("com.pushwoosh.foreground_push", false);
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
+ }
@@ -8,18 +8,19 @@ import com.facebook.react.bridge.NativeModule;
8
8
  import com.facebook.react.bridge.ReactApplicationContext;
9
9
 
10
10
  import java.util.ArrayList;
11
+ import java.util.Arrays;
11
12
  import java.util.Collections;
12
13
  import java.util.List;
13
14
 
14
15
  public class PushwooshPackage implements ReactPackage {
15
- @Override
16
+ // Deprecated from RN 0.47
16
17
  public List<Class<? extends JavaScriptModule>> createJSModules() {
17
18
  return Collections.emptyList();
18
19
  }
19
20
 
20
21
  @Override
21
22
  public List<com.facebook.react.uimanager.ViewManager> createViewManagers(ReactApplicationContext reactContext) {
22
- return Collections.emptyList();
23
+ return Arrays.<com.facebook.react.uimanager.ViewManager>asList(new InlineInAppManager());
23
24
  }
24
25
 
25
26
  @Override
@@ -32,3 +33,4 @@ public class PushwooshPackage implements ReactPackage {
32
33
  return modules;
33
34
  }
34
35
  }
36
+