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,90 @@
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
@@ -1,59 +1,24 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.pushwoosh.reactnativeplugin">
4
-
5
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6
-
7
- <!-- Permission to get DeviceId -->
8
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
9
-
10
- <!-- GCM connects to Google Services. -->
11
- <uses-permission android:name="android.permission.INTERNET" />
12
-
13
- <!-- GCM requires a Google account. -->
14
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
15
-
16
- <!-- Keeps the processor from sleeping when a message is received. -->
17
- <uses-permission android:name="android.permission.WAKE_LOCK" />
18
-
19
- <!-- Enables vibration permission for notification. -->
20
- <uses-permission android:name="android.permission.VIBRATE" />
21
-
22
- <!--
23
- Creates a custom permission so only this app can receive its messages.
24
-
25
- NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE,
26
- where PACKAGE is the application's package name.
27
- -->
28
- <permission
29
- android:name="${applicationId}.permission.C2D_MESSAGE"
30
- android:protectionLevel="signature" />
31
-
32
- <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
33
-
34
- <!-- This app has permission to register and receive data message. -->
35
- <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
36
-
37
- <application
38
- android:allowBackup="true"
39
- android:label="@string/app_name">
40
- <meta-data
41
- android:name="PW_NOTIFICATION_RECEIVER"
42
- android:value="com.pushwoosh.reactnativeplugin.NotificationReceiver" />
43
-
44
- <receiver
45
- android:name="com.google.android.gms.gcm.GcmReceiver"
46
- android:exported="true"
47
- android:permission="com.google.android.c2dm.permission.SEND">
3
+ package="com.pushwoosh.reactnativeplugin">
4
+
5
+ <application>
6
+
7
+ <meta-data
8
+ android:name="com.pushwoosh.notification_service_extension"
9
+ android:value="com.pushwoosh.reactnativeplugin.PushwooshNotificationServiceExtension" />
10
+
11
+ <meta-data
12
+ android:name="com.pushwoosh.internal.plugin_provider"
13
+ android:value="com.pushwoosh.reactnativeplugin.internal.ReactNativePluginProvider" />
14
+
15
+ <!-- <service android:name="com.pushwoosh.reactnativeplugin.CustomFirebaseMessagingService" android:exported="false">
48
16
  <intent-filter>
49
- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
50
-
51
- <category android:name="${applicationId}" />
17
+ <action android:name="com.google.firebase.MESSAGING_EVENT"/>
52
18
  </intent-filter>
53
- </receiver>
54
- <receiver android:name=".NotificationReceiver" />
55
-
56
- <activity android:name=".PostEventActivity"></activity>
57
- </application>
19
+ </service>
20
+ -->
21
+
22
+ </application>
58
23
 
59
- </manifest>
24
+ </manifest>
@@ -1,5 +1,11 @@
1
1
  package com.pushwoosh.reactnativeplugin;
2
2
 
3
+ import android.os.Bundle;
4
+ import android.util.Log;
5
+
6
+ import java.util.ArrayList;
7
+ import java.util.Iterator;
8
+
3
9
  import com.facebook.react.bridge.ReadableArray;
4
10
  import com.facebook.react.bridge.ReadableMap;
5
11
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
@@ -8,160 +14,220 @@ import com.facebook.react.bridge.WritableArray;
8
14
  import com.facebook.react.bridge.WritableMap;
9
15
  import com.facebook.react.bridge.WritableNativeArray;
10
16
  import com.facebook.react.bridge.WritableNativeMap;
17
+ import com.pushwoosh.inbox.data.InboxMessage;
11
18
  import com.pushwoosh.internal.utils.JsonUtils;
12
19
  import com.pushwoosh.internal.utils.PWLog;
20
+ import com.pushwoosh.tags.TagsBundle;
13
21
 
22
+ import org.json.JSONArray;
14
23
  import org.json.JSONException;
15
24
  import org.json.JSONObject;
16
25
 
17
- import java.util.ArrayList;
18
- import java.util.Collections;
19
- import java.util.HashMap;
20
- import java.util.List;
21
- import java.util.Map;
22
-
23
26
  public final class ConversionUtil {
24
27
 
25
- public static Map<String, Object> toMap(ReadableMap readableMap) {
26
- ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
27
- Map<String, Object> result = new HashMap<>();
28
- while (iterator.hasNextKey()) {
29
- String key = iterator.nextKey();
30
- ReadableType type = readableMap.getType(key);
31
- switch (type) {
32
- case Null:
33
- result.put(key, null);
34
- break;
35
- case Boolean:
36
- result.put(key, readableMap.getBoolean(key));
37
- break;
38
- case Number:
39
- result.put(key, readableMap.getDouble(key));
40
- break;
41
- case String:
42
- result.put(key, readableMap.getString(key));
43
- break;
44
- case Map:
45
- result.put(key, toMap(readableMap.getMap(key)));
46
- break;
47
- case Array:
48
- result.put(key, toArray(readableMap.getArray(key)));
49
- break;
50
- default:
51
- PWLog.error(PushwooshPlugin.TAG, "Could not convert object with key: " + key + ".");
52
- }
53
-
54
- }
55
- return result;
56
- }
57
-
58
- public static List<Object> toArray(ReadableArray readableArray) {
59
- List<Object> result = new ArrayList<>(readableArray.size());
60
- for (int i = 0; i < readableArray.size(); i++) {
61
- ReadableType indexType = readableArray.getType(i);
62
- switch(indexType) {
63
- case Null:
64
- result.add(i, null);
65
- break;
66
- case Boolean:
67
- result.add(i, readableArray.getBoolean(i));
68
- break;
69
- case Number:
70
- result.add(i, readableArray.getDouble(i));
71
- break;
72
- case String:
73
- result.add(i, readableArray.getString(i));
74
- break;
75
- case Map:
76
- result.add(i, toMap(readableArray.getMap(i)));
77
- break;
78
- case Array:
79
- result.add(i, toArray(readableArray.getArray(i)));
80
- break;
81
- default:
82
- PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".");
83
- }
84
- }
85
- return result;
86
- }
87
-
88
- public static Map<String, Object> stringToMap(String string) {
89
- try {
90
- JSONObject json = new JSONObject(string);
91
- return JsonUtils.jsonToMap(json);
92
- }
93
- catch (JSONException e) {
94
- PWLog.exception(e);
95
- }
96
-
97
- return Collections.<String, Object>emptyMap();
98
- }
99
-
100
- public static WritableMap toWritableMap(Map<String, Object> map) {
101
- WritableNativeMap result = new WritableNativeMap();
102
-
103
- for(Map.Entry<String, Object> entry : map.entrySet()) {
104
- String key = entry.getKey();
105
- Object value = entry.getValue();
106
- if (value == null) {
107
- result.putNull(key);
108
- }
109
- else if (value instanceof Map) {
110
- result.putMap(key, toWritableMap((Map)value));
111
- }
112
- else if (value instanceof List) {
113
- result.putArray(key, toWritableArray((List) value));
114
- }
115
- else if (value instanceof Boolean) {
116
- result.putBoolean(key, (Boolean)value);
117
- }
118
- else if (value instanceof Integer) {
119
- result.putInt(key, (Integer)value);
120
- }
121
- else if (value instanceof String) {
122
- result.putString(key, (String)value);
123
- }
124
- else if (value instanceof Double) {
125
- result.putDouble(key, (Double)value);
126
- }
127
- else {
128
- PWLog.error(PushwooshPlugin.TAG, "Could not convert object " + value.toString());
129
- }
130
- }
131
-
132
- return result;
133
- }
134
-
135
- public static WritableArray toWritableArray(List<Object> array) {
136
- WritableNativeArray result = new WritableNativeArray();
137
-
138
- for (Object value : array) {
139
- if (value == null) {
140
- result.pushNull();
141
- }
142
- else if (value instanceof Map) {
143
- result.pushMap(toWritableMap((Map) value));
144
- }
145
- else if (value instanceof List) {
146
- result.pushArray(toWritableArray((List) value));
147
- }
148
- else if (value instanceof Boolean) {
149
- result.pushBoolean((Boolean) value);
150
- }
151
- else if (value instanceof Integer) {
152
- result.pushInt((Integer) value);
153
- }
154
- else if (value instanceof String) {
155
- result.pushString((String) value);
156
- }
157
- else if (value instanceof Double) {
158
- result.pushDouble((Double) value);
159
- }
160
- else {
161
- PWLog.error(PushwooshPlugin.TAG, "Could not convert object " + value.toString());
162
- }
163
- }
164
-
165
- return result;
166
- }
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<String> 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<String> messageCodesArrayToArrayList(ReadableArray readableArray) {
218
+ ArrayList<String> 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
+ }
167
233
  }
@@ -0,0 +1,29 @@
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
+ }
@@ -1,14 +1,15 @@
1
1
  package com.pushwoosh.reactnativeplugin;
2
2
 
3
- import com.facebook.react.bridge.Callback;
4
- import com.facebook.react.bridge.ReactContext;
5
- import com.facebook.react.modules.core.DeviceEventManagerModule;
6
-
7
3
  import java.util.ArrayList;
8
4
  import java.util.HashMap;
9
5
  import java.util.List;
10
6
  import java.util.Map;
11
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
+
12
13
  public class EventDispatcher {
13
14
 
14
15
  private Map<String, List<Callback>> subscribers = new HashMap<String, List<Callback>>();
@@ -44,8 +45,8 @@ public class EventDispatcher {
44
45
  }
45
46
  }
46
47
 
47
- public void sendJSEvent(ReactContext reactContext, String event, Map<String, Object> params) {
48
+ public void sendJSEvent(ReactContext reactContext, String event, WritableMap params) {
48
49
  reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
49
- .emit(event, ConversionUtil.toWritableMap(params));
50
+ .emit(event, params);
50
51
  }
51
52
  }