reactnative-plugin-appice 1.6.3 → 1.6.5
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/android/build.gradle +3 -3
- package/android/src/main/AndroidManifest.xml +47 -127
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +151 -21
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +307 -240
- package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +6 -23
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +251 -0
- package/android/src/main/java/com/reactlibrary/NotificationEventService.java +2 -4
- package/example/App.js +76 -0
- package/example/package.json +1 -1
- package/index.js +201 -61
- package/ios/AppIceReactPlugin.h +36 -0
- package/ios/AppIceReactPlugin.m +202 -1
- package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +1 -1
- package/android/src/main/java/com/reactlibrary/ClickCallback.java +0 -5
- package/android/src/main/java/com/reactlibrary/InAppWebView.java +0 -68
package/android/build.gradle
CHANGED
|
@@ -69,7 +69,7 @@ repositories {
|
|
|
69
69
|
url "https://gitlab.com/api/v4/projects/10636887/packages/maven"
|
|
70
70
|
credentials(HttpHeaderCredentials) {
|
|
71
71
|
name = "Deploy-Token"
|
|
72
|
-
value = "
|
|
72
|
+
value = "PJMsxXdArqsmqDx4x5B6"
|
|
73
73
|
}
|
|
74
74
|
authentication {
|
|
75
75
|
header(HttpHeaderAuthentication)
|
|
@@ -114,12 +114,12 @@ dependencies {
|
|
|
114
114
|
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
115
115
|
|
|
116
116
|
//appice
|
|
117
|
-
implementation 'appice.io.android:sdk:2.5.
|
|
117
|
+
implementation 'appice.io.android:sdk:2.5.66-release'
|
|
118
|
+
//implementation files('libs/libsdk-release.aar')
|
|
118
119
|
|
|
119
120
|
//glide
|
|
120
121
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
|
121
122
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
|
122
|
-
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
def configureReactNativePom(def pom) {
|
|
@@ -4,33 +4,27 @@
|
|
|
4
4
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
5
5
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
6
6
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
7
|
-
<uses-permission android:name="android.permission.INTERNET"/>
|
|
7
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
8
8
|
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
|
9
|
-
<uses-permission android:name="android.permission.VIBRATE"/>
|
|
9
|
+
<uses-permission android:name="android.permission.VIBRATE" />
|
|
10
10
|
|
|
11
|
-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
12
|
-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
|
13
|
-
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
|
|
11
|
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
12
|
+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
13
|
+
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
|
14
14
|
|
|
15
15
|
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
<permission
|
|
19
|
-
android:name="${applicationId}.permission.MIPUSH_RECEIVE"
|
|
20
|
-
android:protectionLevel="signature" />
|
|
21
|
-
|
|
22
|
-
<uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE" />
|
|
23
|
-
|
|
24
17
|
<application>
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
<service
|
|
19
|
+
android:name="com.reactlibrary.NotificationEventService"
|
|
27
20
|
android:exported="false">
|
|
28
21
|
<intent-filter>
|
|
29
22
|
<action android:name="com.appice.campaignEvent" />
|
|
30
23
|
</intent-filter>
|
|
31
24
|
</service>
|
|
32
25
|
|
|
33
|
-
<receiver
|
|
26
|
+
<receiver
|
|
27
|
+
android:name="com.reactlibrary.CampaignCampsReceiver"
|
|
34
28
|
android:exported="false">
|
|
35
29
|
<intent-filter>
|
|
36
30
|
<action android:name="com.appice.campaignEvent" />
|
|
@@ -41,42 +35,31 @@
|
|
|
41
35
|
<service
|
|
42
36
|
android:name="semusi.activitysdk.Api"
|
|
43
37
|
android:exported="false"
|
|
44
|
-
android:protectionLevel="signature"/>
|
|
45
|
-
<activity
|
|
46
|
-
|
|
47
|
-
android:name="com.xiaomi.mipush.sdk.NotificationClickedActivity"
|
|
48
|
-
|
|
49
|
-
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
|
38
|
+
android:protectionLevel="signature" />
|
|
50
39
|
|
|
51
|
-
android:launchMode="singleInstance"
|
|
52
|
-
|
|
53
|
-
android:exported="false"
|
|
54
|
-
|
|
55
|
-
android:enabled="true">
|
|
56
|
-
|
|
57
|
-
</activity>
|
|
58
40
|
<activity
|
|
59
41
|
android:name="semusi.context.ui.UIEventsHandler"
|
|
60
42
|
android:exported="false"
|
|
61
43
|
android:protectionLevel="signature"
|
|
62
|
-
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
|
|
44
|
+
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
|
|
63
45
|
|
|
64
|
-
<activity
|
|
46
|
+
<activity
|
|
47
|
+
android:name="semusi.context.ui.AppICENotifUI"
|
|
65
48
|
android:exported="false">
|
|
66
49
|
<intent-filter>
|
|
67
|
-
<action android:name="AppICE.Notification.FCM_Action"/>
|
|
68
|
-
<category android:name="android.intent.category.DEFAULT"/>
|
|
50
|
+
<action android:name="AppICE.Notification.FCM_Action" />
|
|
51
|
+
<category android:name="android.intent.category.DEFAULT" />
|
|
69
52
|
</intent-filter>
|
|
70
53
|
|
|
71
54
|
<intent-filter>
|
|
72
|
-
<action android:name="android.intent.action.VIEW"/>
|
|
55
|
+
<action android:name="android.intent.action.VIEW" />
|
|
73
56
|
|
|
74
|
-
<category android:name="android.intent.category.DEFAULT"/>
|
|
75
|
-
<category android:name="android.intent.category.BROWSABLE"/>
|
|
57
|
+
<category android:name="android.intent.category.DEFAULT" />
|
|
58
|
+
<category android:name="android.intent.category.BROWSABLE" />
|
|
76
59
|
|
|
77
60
|
<data
|
|
78
61
|
android:host="ai.io"
|
|
79
|
-
android:scheme="https"/>
|
|
62
|
+
android:scheme="https" />
|
|
80
63
|
</intent-filter>
|
|
81
64
|
</activity>
|
|
82
65
|
|
|
@@ -85,7 +68,7 @@
|
|
|
85
68
|
android:exported="false"
|
|
86
69
|
android:protectionLevel="signature">
|
|
87
70
|
<intent-filter>
|
|
88
|
-
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
71
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
89
72
|
</intent-filter>
|
|
90
73
|
</service>
|
|
91
74
|
|
|
@@ -94,141 +77,78 @@
|
|
|
94
77
|
android:exported="false"
|
|
95
78
|
android:protectionLevel="signature">
|
|
96
79
|
<intent-filter android:priority="9999">
|
|
97
|
-
<action android:name="android.intent.action.PACKAGE_ADDED"/>
|
|
98
|
-
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
|
99
|
-
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
|
|
80
|
+
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
|
81
|
+
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
|
82
|
+
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
|
100
83
|
|
|
101
|
-
<data android:scheme="package"/>
|
|
84
|
+
<data android:scheme="package" />
|
|
102
85
|
</intent-filter>
|
|
103
86
|
</receiver>
|
|
104
87
|
|
|
105
88
|
<receiver
|
|
106
89
|
android:name="semusi.context.counthandler.DataSyncReceiver"
|
|
107
90
|
android:exported="false"
|
|
108
|
-
android:protectionLevel="signature"/>
|
|
91
|
+
android:protectionLevel="signature" />
|
|
109
92
|
<receiver
|
|
110
93
|
android:name="semusi.context.counthandler.TimeTickReceiver"
|
|
111
94
|
android:exported="false"
|
|
112
|
-
android:protectionLevel="signature"/>
|
|
95
|
+
android:protectionLevel="signature" />
|
|
113
96
|
<receiver
|
|
114
97
|
android:name="semusi.context.counthandler.NotificationEventReceiver"
|
|
115
98
|
android:exported="false"
|
|
116
|
-
android:protectionLevel="signature"/>
|
|
99
|
+
android:protectionLevel="signature" />
|
|
117
100
|
<receiver
|
|
118
101
|
android:name="semusi.context.counthandler.ActionEventReceiver"
|
|
119
102
|
android:exported="false"
|
|
120
|
-
android:protectionLevel="signature"/>
|
|
103
|
+
android:protectionLevel="signature" />
|
|
121
104
|
<receiver
|
|
122
105
|
android:name="semusi.analytics.handler.SessionReceiver"
|
|
123
106
|
android:exported="false"
|
|
124
|
-
android:protectionLevel="signature"/>
|
|
107
|
+
android:protectionLevel="signature" />
|
|
125
108
|
|
|
126
109
|
<receiver
|
|
127
110
|
android:name="semusi.context.counthandler.DeviceBootReceiver"
|
|
128
|
-
android:
|
|
129
|
-
android:
|
|
111
|
+
android:exported="false"
|
|
112
|
+
android:protectionLevel="signature">
|
|
130
113
|
<intent-filter>
|
|
131
|
-
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
|
132
|
-
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
|
|
133
|
-
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
|
|
114
|
+
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
115
|
+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
|
116
|
+
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
|
134
117
|
</intent-filter>
|
|
135
118
|
</receiver>
|
|
136
119
|
|
|
137
120
|
<service
|
|
138
121
|
android:name="semusi.ruleengine.pushmanager.NotificationEventService"
|
|
139
|
-
android:permission="android.permission.BIND_JOB_SERVICE">
|
|
140
|
-
</service>
|
|
122
|
+
android:permission="android.permission.BIND_JOB_SERVICE"></service>
|
|
141
123
|
<!-- Semusi setup end -->
|
|
142
124
|
<!-- Semusi Job Start -->
|
|
143
125
|
|
|
144
|
-
<receiver
|
|
126
|
+
<receiver
|
|
127
|
+
android:name="semusi.context.ui.Carousel.CarouselEventReceiver"
|
|
145
128
|
android:exported="false">
|
|
146
129
|
<intent-filter>
|
|
147
|
-
<action android:name="io.appice.CAROUSELNOTIFICATIONFIRED"/>
|
|
130
|
+
<action android:name="io.appice.CAROUSELNOTIFICATIONFIRED" />
|
|
148
131
|
</intent-filter>
|
|
149
132
|
</receiver>
|
|
150
133
|
|
|
151
134
|
|
|
152
|
-
|
|
153
135
|
<!--</receiver>-->
|
|
154
|
-
<receiver android:name="semusi.geofencing.AIGeofenceReceiver"
|
|
155
|
-
android:exported="false">
|
|
156
|
-
</receiver>
|
|
157
|
-
|
|
158
|
-
<receiver android:name="semusi.geofencing.LocationUpdateReceiver"
|
|
159
|
-
android:exported="false">
|
|
160
|
-
</receiver>
|
|
161
|
-
|
|
162
|
-
<receiver android:name="semusi.geofencing.AIGeofenceBootReceiver"
|
|
163
|
-
android:exported="false">
|
|
164
|
-
<intent-filter>
|
|
165
|
-
<action android:name="android.location.PROVIDERS_CHANGED"/>
|
|
166
|
-
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
|
167
|
-
</intent-filter>
|
|
168
|
-
</receiver>
|
|
169
|
-
<receiver android:name="semusi.geofencing.GeofenceReceiver"/>
|
|
170
|
-
|
|
171
136
|
<receiver
|
|
172
|
-
android:name="semusi.
|
|
173
|
-
android:exported="false">
|
|
174
|
-
<intent-filter>
|
|
175
|
-
<action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE" />
|
|
176
|
-
</intent-filter>
|
|
177
|
-
<intent-filter>
|
|
178
|
-
<action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED" />
|
|
179
|
-
</intent-filter>
|
|
180
|
-
<intent-filter>
|
|
181
|
-
<action android:name="com.xiaomi.mipush.ERROR" />
|
|
182
|
-
</intent-filter>
|
|
183
|
-
</receiver>
|
|
184
|
-
|
|
137
|
+
android:name="semusi.geofencing.AIGeofenceReceiver"
|
|
138
|
+
android:exported="false"></receiver>
|
|
185
139
|
|
|
186
140
|
<receiver
|
|
187
|
-
android:name="
|
|
188
|
-
android:exported="false">
|
|
189
|
-
<intent-filter>
|
|
190
|
-
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
|
191
|
-
|
|
192
|
-
<category android:name="android.intent.category.DEFAULT" />
|
|
193
|
-
</intent-filter>
|
|
194
|
-
</receiver>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<!-- // xiaomi setting-->
|
|
199
|
-
<service
|
|
200
|
-
android:name="com.xiaomi.push.service.XMPushService"
|
|
201
|
-
android:exported="false"
|
|
202
|
-
android:enabled="false"
|
|
203
|
-
android:process=":pushservice" />
|
|
204
|
-
|
|
205
|
-
<!--Note: This service must be added to the version 3.0.1 or later (including version 3.0.1)-->
|
|
206
|
-
<service
|
|
207
|
-
android:name="com.xiaomi.push.service.XMJobService"
|
|
208
|
-
android:enabled="true"
|
|
209
|
-
android:exported="false"
|
|
210
|
-
android:permission="android.permission.BIND_JOB_SERVICE"
|
|
211
|
-
android:process=":pushservice" />
|
|
212
|
-
|
|
213
|
-
<service
|
|
214
|
-
android:name="com.xiaomi.mipush.sdk.PushMessageHandler"
|
|
215
|
-
android:enabled="true"
|
|
216
|
-
android:exported="false" />
|
|
217
|
-
|
|
218
|
-
<!--Note: This service must be added to version 2.2.5 or later (including version 2.2.5)-->
|
|
219
|
-
<service
|
|
220
|
-
android:name="com.xiaomi.mipush.sdk.MessageHandleService"
|
|
221
|
-
android:exported="false"
|
|
222
|
-
android:enabled="true" />
|
|
141
|
+
android:name="semusi.geofencing.LocationUpdateReceiver"
|
|
142
|
+
android:exported="false"></receiver>
|
|
223
143
|
|
|
224
144
|
<receiver
|
|
225
|
-
android:name="
|
|
226
|
-
android:exported="false"
|
|
227
|
-
android:process=":pushservice">
|
|
145
|
+
android:name="semusi.geofencing.AIGeofenceBootReceiver"
|
|
146
|
+
android:exported="false">
|
|
228
147
|
<intent-filter>
|
|
229
|
-
<action android:name="
|
|
148
|
+
<action android:name="android.location.PROVIDERS_CHANGED" />
|
|
149
|
+
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
230
150
|
</intent-filter>
|
|
231
151
|
</receiver>
|
|
232
|
-
|
|
152
|
+
<receiver android:name="semusi.geofencing.GeofenceReceiver" />
|
|
233
153
|
</application>
|
|
234
154
|
</manifest>
|
|
@@ -1,38 +1,168 @@
|
|
|
1
1
|
package com.reactlibrary;
|
|
2
2
|
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
|
|
5
3
|
import com.facebook.react.bridge.Arguments;
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
7
|
+
import com.facebook.react.bridge.ReadableType;
|
|
8
|
+
import com.facebook.react.bridge.WritableArray;
|
|
6
9
|
import com.facebook.react.bridge.WritableMap;
|
|
7
10
|
|
|
8
|
-
import
|
|
9
|
-
|
|
11
|
+
import java.util.ArrayList;
|
|
12
|
+
import java.util.HashMap;
|
|
10
13
|
import java.util.Iterator;
|
|
11
14
|
import java.util.Map;
|
|
12
15
|
|
|
16
|
+
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
17
|
+
|
|
13
18
|
public class AppICEUtils {
|
|
14
19
|
private static final String TAG = "AppICEUtils";
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
public static WritableMap convertClassToWritableMap(AppICEInboxMessage inboxMessage){
|
|
22
|
+
WritableMap inboxObject = Arguments.createMap();
|
|
23
|
+
try {
|
|
24
|
+
if (inboxMessage != null) {
|
|
25
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE_ID.getValue(), inboxMessage.getMessageId());
|
|
26
|
+
inboxObject.putString(EnumConstants.INBOX_CAMPAIGN_ID.getValue(), inboxMessage.getCampId());
|
|
27
|
+
inboxObject.putString(EnumConstants.INBOX_CAMPAIGN_TYPE.getValue(), inboxMessage.getMessageCampType());
|
|
28
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE_CATEGORY.getValue(), inboxMessage.getCategory());
|
|
29
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE_STATUS.getValue(), inboxMessage.getMessageStatus());
|
|
30
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE_LANGUAGE.getValue(), inboxMessage.getMessageLanguage());
|
|
31
|
+
inboxObject.putString(EnumConstants.INBOX_TITLE.getValue(), inboxMessage.getMessageTitle());
|
|
32
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE.getValue(), inboxMessage.getMessageBody());
|
|
33
|
+
inboxObject.putString(EnumConstants.INBOX_MESSAGE_ICON.getValue(), inboxMessage.getMessageIcon());
|
|
34
|
+
inboxObject.putMap(EnumConstants.INBOX_CUSTOM_DATA.getValue(), toWritableMap(inboxMessage.getCustomData()));
|
|
35
|
+
}
|
|
36
|
+
}catch (Throwable throwable){}
|
|
37
|
+
return inboxObject;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
42
|
+
WritableMap writableMap = Arguments.createMap();
|
|
43
|
+
Iterator iterator = map.entrySet().iterator();
|
|
44
|
+
|
|
45
|
+
while (iterator.hasNext()) {
|
|
46
|
+
Map.Entry pair = (Map.Entry) iterator.next();
|
|
47
|
+
writableMap.merge(addValue((String) pair.getKey(), pair.getValue()));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return writableMap;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static WritableMap addValue(String key, Object value) {
|
|
54
|
+
WritableMap writableMap = Arguments.createMap();
|
|
55
|
+
if (value == null) {
|
|
56
|
+
writableMap.putNull(key);
|
|
57
|
+
} else if (value instanceof Boolean) {
|
|
58
|
+
writableMap.putBoolean(key, (Boolean) value);
|
|
59
|
+
} else if (value instanceof Double) {
|
|
60
|
+
writableMap.putDouble(key, (Double) value);
|
|
61
|
+
} else if (value instanceof Integer) {
|
|
62
|
+
writableMap.putInt(key, (Integer) value);
|
|
63
|
+
} else if (value instanceof String) {
|
|
64
|
+
writableMap.putString(key, (String) value);
|
|
65
|
+
} else if (value instanceof Map) {
|
|
66
|
+
writableMap.putMap(key, toWritableMap((Map<String, Object>) value));
|
|
67
|
+
} else if (value.getClass() != null && (value.getClass().isArray() || value instanceof ArrayList)) {
|
|
68
|
+
writableMap.putArray(key, toWritableArray((ArrayList) value));
|
|
69
|
+
}
|
|
70
|
+
return writableMap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public static WritableArray toWritableArray(ArrayList arrayList) {
|
|
74
|
+
WritableArray writableArray = Arguments.createArray();
|
|
75
|
+
|
|
76
|
+
for (int i = 0; i < arrayList.size(); i++) {
|
|
77
|
+
Object value = arrayList.get(i);
|
|
78
|
+
|
|
79
|
+
if (value == null) {
|
|
80
|
+
writableArray.pushNull();
|
|
29
81
|
}
|
|
82
|
+
if (value instanceof Boolean) {
|
|
83
|
+
writableArray.pushBoolean((Boolean) value);
|
|
84
|
+
}
|
|
85
|
+
if (value instanceof Double) {
|
|
86
|
+
writableArray.pushDouble((Double) value);
|
|
87
|
+
}
|
|
88
|
+
if (value instanceof Integer) {
|
|
89
|
+
writableArray.pushInt((Integer) value);
|
|
90
|
+
}
|
|
91
|
+
if (value instanceof String) {
|
|
92
|
+
writableArray.pushString((String) value);
|
|
93
|
+
}
|
|
94
|
+
if (value instanceof Map) {
|
|
95
|
+
writableArray.pushMap(toWritableMap((Map<String, Object>) value));
|
|
96
|
+
}
|
|
97
|
+
if (value.getClass().isArray()) {
|
|
98
|
+
writableArray.pushArray(toWritableArray((ArrayList) value));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return writableArray;
|
|
103
|
+
}
|
|
104
|
+
|
|
30
105
|
|
|
31
|
-
|
|
32
|
-
|
|
106
|
+
public static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
|
|
107
|
+
ArrayList<String> array = new ArrayList<>();
|
|
108
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
109
|
+
switch (readableArray.getType(i)) {
|
|
110
|
+
case Null:
|
|
111
|
+
break;
|
|
112
|
+
case Boolean:
|
|
113
|
+
array.add(String.valueOf(readableArray.getBoolean(i)));
|
|
114
|
+
break;
|
|
115
|
+
case Number:
|
|
116
|
+
array.add(String.valueOf(readableArray.getDouble(i)));
|
|
117
|
+
break;
|
|
118
|
+
case String:
|
|
119
|
+
array.add(readableArray.getString(i));
|
|
120
|
+
break;
|
|
33
121
|
}
|
|
34
122
|
}
|
|
35
|
-
return
|
|
123
|
+
return array;
|
|
36
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param propsMap took data from js and iterate it and store in hashmap
|
|
128
|
+
* @return map of the props data
|
|
129
|
+
*/
|
|
130
|
+
public static HashMap<String, Object> eventPropsFromReadableMap(ReadableMap propsMap) {
|
|
131
|
+
if (propsMap == null) return null;
|
|
37
132
|
|
|
38
|
-
|
|
133
|
+
HashMap<String, Object> props = new HashMap<>();
|
|
134
|
+
ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
|
|
135
|
+
|
|
136
|
+
while (iterator.hasNextKey()) {
|
|
137
|
+
try {
|
|
138
|
+
String key = iterator.nextKey();
|
|
139
|
+
ReadableType readableType = propsMap.getType(key);
|
|
140
|
+
|
|
141
|
+
if (readableType == ReadableType.String) {
|
|
142
|
+
props.put(key, propsMap.getString(key));
|
|
143
|
+
} else if (readableType == ReadableType.Boolean) {
|
|
144
|
+
props.put(key, propsMap.getBoolean(key));
|
|
145
|
+
} else if (readableType == ReadableType.Number) {
|
|
146
|
+
try {
|
|
147
|
+
props.put(key, propsMap.getDouble(key));
|
|
148
|
+
} catch (Throwable t) {
|
|
149
|
+
try {
|
|
150
|
+
props.put(key, propsMap.getInt(key));
|
|
151
|
+
} catch (Throwable t1) {
|
|
152
|
+
AppICEUtils.printLog(TAG, "Unhandled ReadableType.Number from ReadableMap");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
AppICEUtils.printLog(TAG, "Unhandled event property ReadableType");
|
|
157
|
+
}
|
|
158
|
+
} catch (Throwable t) {
|
|
159
|
+
AppICEUtils.printLog(TAG, t.getLocalizedMessage());
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return props;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public static void printLog(String TAG, String message){
|
|
166
|
+
System.out.println(TAG+", "+message);
|
|
167
|
+
}
|
|
168
|
+
}
|