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.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +135 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +31 -0
- package/.github/ISSUE_TEMPLATE/question.yml +28 -0
- package/InlineInApp.js +71 -0
- package/README.md +35 -85
- package/docs/README.md +230 -11
- package/index.d.ts +91 -0
- package/index.js +265 -24
- package/package.json +12 -1
- package/pushwoosh-react-native-plugin.podspec +20 -0
- package/react-native.config.js +9 -0
- package/scripts/add_inbox_ios_resources.js +42 -0
- package/src/android/build.gradle +40 -10
- package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/android/gradlew +160 -0
- package/src/android/gradlew.bat +90 -0
- package/src/android/src/main/AndroidManifest.xml +19 -54
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/ConversionUtil.java +214 -148
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/CustomFirebaseMessagingService.java +29 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/EventDispatcher.java +7 -6
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InboxUiStyleManager.java +162 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InlineInAppManager.java +48 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshNotificationServiceExtension.java +44 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPackage.java +4 -2
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +606 -393
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/RCTInlineInAppView.java +75 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/internal/ReactNativePluginProvider.java +15 -0
- package/src/ios/PWAppDelegate.h +20 -0
- package/src/ios/PWGDPRManager.h +46 -0
- package/src/ios/PWIInboxStyle.h +122 -0
- package/src/ios/PWIInboxUI.h +39 -0
- package/src/ios/PWInAppManager.h +176 -0
- package/src/ios/PWInbox.h +147 -0
- package/src/ios/PWInlineInAppView.h +26 -0
- package/src/ios/PWLog.h +23 -0
- package/src/ios/PWMessaging.h +20 -0
- package/src/ios/PWNotificationExtensionManager.h +46 -0
- package/src/ios/PWRichMediaManager.h +123 -0
- package/src/ios/PWRichMediaStyle.h +122 -0
- package/src/ios/PushNotificationManager.h +234 -111
- package/src/ios/Pushwoosh.h +623 -0
- package/src/ios/PushwooshInboxBundle.bundle/Info.plist +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/PWIInboxAttachmentViewController.nib +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/PWIInboxMessageViewCell.nib +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/PWIInboxViewController.nib +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/errorMessage@2x.png +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/inbox_icon.png +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/noMessage@2x.png +0 -0
- package/src/ios/PushwooshInboxBundle.bundle/unread.png +0 -0
- package/src/ios/PushwooshInboxUI.h +19 -0
- package/src/ios/PushwooshPlugin/PWEventDispatcher.h +1 -1
- package/src/ios/PushwooshPlugin/PWInlineInAppManager.h +17 -0
- package/src/ios/PushwooshPlugin/PWInlineInAppManager.m +54 -0
- package/src/ios/PushwooshPlugin/Pushwoosh.h +18 -3
- package/src/ios/PushwooshPlugin/Pushwoosh.m +532 -98
- package/src/ios/PushwooshPlugin.xcodeproj/project.pbxproj +27 -6
- package/src/ios/libPushwoosh.a +0 -0
- package/src/ios/libPushwooshInboxUI.a +0 -0
- package/.npmignore +0 -3
- package/src/android/.npmignore +0 -1
- package/src/android/pushwooshplugin.iml +0 -150
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/NotificationReceiver.java +0 -42
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PostEventActivity.java +0 -45
- package/src/ios/Pushwoosh.a +0 -0
- 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
50
|
-
|
|
51
|
-
<category android:name="${applicationId}" />
|
|
17
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
52
18
|
</intent-filter>
|
|
53
|
-
</
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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,
|
|
48
|
+
public void sendJSEvent(ReactContext reactContext, String event, WritableMap params) {
|
|
48
49
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
49
|
-
.emit(event,
|
|
50
|
+
.emit(event, params);
|
|
50
51
|
}
|
|
51
52
|
}
|