cordova-plugin-appice 2.1.1 → 2.1.3
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/package.json +1 -1
- package/plugin.xml +6 -2
- package/src/android/AppICEPlugin.java +103 -96
- package/src/android/AppICEPushHandler.java +1 -1
- package/src/ios/AppICEPlugin.h +3 -0
- package/src/ios/AppICEPlugin.m +18 -29
- package/www/AppICE.js +39 -20
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
2
|
+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
+
id="cordova-plugin-appice" version="2.1.3">
|
|
3
4
|
<name>AppICE</name>
|
|
4
5
|
<description>AppICE Plugin for Cordova/PhoneGap</description>
|
|
5
6
|
<license>Commercial</license>
|
|
@@ -113,12 +114,15 @@
|
|
|
113
114
|
<preference name="WORK_MANAGER_VERSION" default="2.7.1"/>
|
|
114
115
|
|
|
115
116
|
<!-- AppICE VERSION-->
|
|
116
|
-
<preference name="APPICE_VERSION" default="2.5.
|
|
117
|
+
<preference name="APPICE_VERSION" default="2.5.70-release"/>
|
|
117
118
|
|
|
118
119
|
|
|
119
120
|
<!-- USES PERMISSION -->
|
|
120
121
|
<config-file target="AndroidManifest.xml" parent="/manifest">
|
|
121
122
|
<uses-permission android:name="android.permission.INTERNET"/>
|
|
123
|
+
|
|
124
|
+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
|
125
|
+
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
|
|
122
126
|
</config-file>
|
|
123
127
|
|
|
124
128
|
<!-- MANIFEST ENTRIES -->
|
|
@@ -2,9 +2,9 @@ package com.appice.cordova;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.content.Intent;
|
|
5
|
+
import android.content.SharedPreferences;
|
|
5
6
|
import android.content.pm.PackageManager;
|
|
6
7
|
import android.content.pm.ResolveInfo;
|
|
7
|
-
import android.net.Uri;
|
|
8
8
|
import android.os.Build;
|
|
9
9
|
import android.os.Bundle;
|
|
10
10
|
import android.os.Handler;
|
|
@@ -29,18 +29,22 @@ import java.util.HashMap;
|
|
|
29
29
|
import java.util.Iterator;
|
|
30
30
|
import java.util.List;
|
|
31
31
|
import java.util.Map;
|
|
32
|
-
import java.util.Timer;
|
|
33
|
-
import java.util.TimerTask;
|
|
34
32
|
|
|
35
33
|
import semusi.activitysdk.Api;
|
|
36
34
|
import semusi.activitysdk.ContextData;
|
|
37
35
|
import semusi.activitysdk.ContextSdk;
|
|
38
36
|
import semusi.activitysdk.SdkConfig;
|
|
39
37
|
import semusi.activitysdk.User;
|
|
38
|
+
import semusi.context.utility.Utility;
|
|
39
|
+
|
|
40
40
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
41
41
|
|
|
42
42
|
public class AppICEPlugin extends CordovaPlugin {
|
|
43
43
|
|
|
44
|
+
private final String CALLBACK_CONSTANTS = "pendingCallback";
|
|
45
|
+
private static final String TEMP_DB = "AppICETempDB";
|
|
46
|
+
|
|
47
|
+
private static boolean statusFlag = false;
|
|
44
48
|
private static final String TAG = AppICEPlugin.class.getSimpleName();
|
|
45
49
|
private static final Map<String, Method> exportedMethods;
|
|
46
50
|
private static boolean inBackground = true;
|
|
@@ -48,7 +52,8 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
48
52
|
private static CallbackContext callbackContext;
|
|
49
53
|
|
|
50
54
|
@Retention(RUNTIME)
|
|
51
|
-
@interface CordovaMethod {
|
|
55
|
+
@interface CordovaMethod {
|
|
56
|
+
}
|
|
52
57
|
|
|
53
58
|
static {
|
|
54
59
|
HashMap<String, Method> methods = new HashMap<String, Method>();
|
|
@@ -69,7 +74,6 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
69
74
|
|
|
70
75
|
@Override
|
|
71
76
|
public void onResume(boolean multitasking) {
|
|
72
|
-
AppICEPlugin.inBackground = false;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
@Override
|
|
@@ -77,6 +81,15 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
77
81
|
AppICEPlugin.notificationCallbackContext = null;
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
@Override
|
|
85
|
+
public void onDestroy() {
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Override
|
|
89
|
+
public void onStop() {
|
|
90
|
+
statusFlag = false;
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
public static boolean inBackground() {
|
|
81
94
|
return AppICEPlugin.inBackground;
|
|
82
95
|
}
|
|
@@ -89,107 +102,39 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
89
102
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
|
90
103
|
super.initialize(cordova, webView);
|
|
91
104
|
|
|
105
|
+
|
|
92
106
|
onNewIntent(cordova.getActivity().getIntent());
|
|
93
107
|
}
|
|
94
108
|
|
|
95
109
|
public void onNewIntent(Intent intent) {
|
|
96
110
|
if (intent == null) return;
|
|
97
|
-
System.out.println("onNewIntent intent "+intent);
|
|
98
111
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
Bundle extras = intent.getExtras();
|
|
113
|
+
String payload = extras.getString("ai_content");
|
|
114
|
+
boolean isPushNotification = (payload != null && payload.length() > 0) ? true : false;
|
|
115
|
+
if (isPushNotification) {
|
|
116
|
+
JSONObject data = new JSONObject(payload);
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
final String json = "{'payload':" + data.toString() + "}";
|
|
119
|
+
System.out.println("AppICE : onNewIntent : json "+json);
|
|
120
|
+
if (statusFlag) {
|
|
121
|
+
webView.getView().post(new Runnable() {
|
|
105
122
|
@Override
|
|
106
123
|
public void run() {
|
|
107
|
-
webView.loadUrl("javascript:cordova.fireDocumentEvent('
|
|
124
|
+
webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + json + ");");
|
|
108
125
|
}
|
|
109
126
|
});
|
|
127
|
+
} else {
|
|
128
|
+
storeTempData(CALLBACK_CONSTANTS, json, cordova.getActivity());
|
|
110
129
|
}
|
|
111
|
-
}
|
|
112
|
-
// push notification
|
|
113
|
-
else {
|
|
114
|
-
|
|
115
|
-
new Timer("AppICE-NotifService-Timer").schedule(new TimerTask() {
|
|
116
|
-
@Override
|
|
117
|
-
public void run() {
|
|
118
|
-
|
|
119
|
-
try{
|
|
120
|
-
String url = "";
|
|
121
|
-
Bundle extras = intent.getExtras();
|
|
122
|
-
System.out.println("onNewIntent bundle "+extras);
|
|
123
|
-
String payload = extras.getString("ai_content");
|
|
124
|
-
boolean isPushNotification = (payload != null && payload.length()>0)?true:false;
|
|
125
|
-
if (isPushNotification) {
|
|
126
|
-
JSONObject data = new JSONObject(payload);
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
url = data.optString("eurl");
|
|
130
|
-
if (data.has("cdata")) {
|
|
131
|
-
JSONObject cDATA = data.optJSONObject("cdata");
|
|
132
|
-
String test = cDATA.optString("eurl");
|
|
133
|
-
if (test != null && test.length()>0){
|
|
134
|
-
url = test;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
System.out.println("chromium : url "+url);
|
|
138
|
-
if (url != null && url.length()>0){
|
|
139
|
-
final String json = "{'deeplink':'" + url + "'}";
|
|
140
|
-
|
|
141
|
-
webView.getView().post(new Runnable() {
|
|
142
|
-
@Override
|
|
143
|
-
public void run() {
|
|
144
|
-
webView.loadUrl("javascript:cordova.fireDocumentEvent('onDeepLink'," + json + ");");
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
}catch (Throwable t){
|
|
150
|
-
Log.e(TAG, "onNewIntent: customDeeplinkError ", t );
|
|
151
|
-
}
|
|
152
130
|
|
|
153
|
-
|
|
154
|
-
final String json = "{'payload':" + data.toString() + "}";
|
|
155
|
-
webView.getView().post(new Runnable() {
|
|
156
|
-
@Override
|
|
157
|
-
public void run() {
|
|
158
|
-
webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + json + ");");
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
if (data.has("cdata")) {
|
|
164
|
-
JSONObject cDATA = data.optJSONObject("cdata");
|
|
165
|
-
final String customData = "{'customData':'" + cDATA.toString() + "'}";
|
|
166
|
-
|
|
167
|
-
webView.getView().post(new Runnable() {
|
|
168
|
-
@Override
|
|
169
|
-
public void run() {
|
|
170
|
-
webView.loadUrl("javascript:cordova.fireDocumentEvent('onCustomDataCallback'," + customData + ");");
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}catch (Throwable t){
|
|
175
|
-
Log.e(TAG, "onNewIntent: customDataError ", t);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}catch (Throwable throwable){}
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
}, 1000);
|
|
131
|
+
ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
|
|
186
132
|
}
|
|
187
|
-
}catch (Throwable throwable){
|
|
133
|
+
} catch (Throwable throwable) {
|
|
134
|
+
Log.e(TAG, "onNewIntent: error ", throwable);
|
|
188
135
|
}
|
|
189
|
-
|
|
190
136
|
}
|
|
191
137
|
|
|
192
|
-
|
|
193
138
|
@Override
|
|
194
139
|
public boolean execute(String action, JSONArray data, CallbackContext callbackId) {
|
|
195
140
|
Method method = exportedMethods.get(action);
|
|
@@ -297,6 +242,31 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
297
242
|
}
|
|
298
243
|
}
|
|
299
244
|
|
|
245
|
+
@CordovaMethod
|
|
246
|
+
private void isDeviceReady(JSONArray data, CallbackContext callbackContext) {
|
|
247
|
+
try {
|
|
248
|
+
if (statusFlag==false) {
|
|
249
|
+
checkIfAnyPendingCallback(cordova.getActivity());
|
|
250
|
+
}
|
|
251
|
+
statusFlag = true;
|
|
252
|
+
callbackContext.success();
|
|
253
|
+
|
|
254
|
+
} catch (Throwable e) {
|
|
255
|
+
callbackContext.error(e.getMessage());
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private void checkIfAnyPendingCallback(Context context) {
|
|
260
|
+
String pendingCallbackStr = loadTempData(CALLBACK_CONSTANTS, context);
|
|
261
|
+
webView.getView().post(new Runnable() {
|
|
262
|
+
@Override
|
|
263
|
+
public void run() {
|
|
264
|
+
webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + pendingCallbackStr + ");");
|
|
265
|
+
resetTempData(CALLBACK_CONSTANTS, context);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
300
270
|
@CordovaMethod
|
|
301
271
|
private void stopContext(JSONArray data, CallbackContext callbackContext) {
|
|
302
272
|
try {
|
|
@@ -323,7 +293,7 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
323
293
|
};
|
|
324
294
|
mainHandler.post(myRunnable);
|
|
325
295
|
|
|
326
|
-
}catch (Throwable t){
|
|
296
|
+
} catch (Throwable t) {
|
|
327
297
|
callbackContext.error(t.getMessage());
|
|
328
298
|
}
|
|
329
299
|
}
|
|
@@ -697,9 +667,9 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
697
667
|
}
|
|
698
668
|
|
|
699
669
|
@CordovaMethod
|
|
700
|
-
private void pushNotificationClicked(JSONArray data, final CallbackContext callbackContext){
|
|
670
|
+
private void pushNotificationClicked(JSONArray data, final CallbackContext callbackContext) {
|
|
701
671
|
try {
|
|
702
|
-
if(data != null){
|
|
672
|
+
if (data != null) {
|
|
703
673
|
String payload = (String) data.getJSONObject(0).get("pushPayload");
|
|
704
674
|
ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
|
|
705
675
|
callbackContext.success();
|
|
@@ -711,9 +681,9 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
711
681
|
}
|
|
712
682
|
|
|
713
683
|
@CordovaMethod
|
|
714
|
-
private void getDeepLinkURL(JSONArray data, final CallbackContext callbackContext){
|
|
684
|
+
private void getDeepLinkURL(JSONArray data, final CallbackContext callbackContext) {
|
|
715
685
|
try {
|
|
716
|
-
if(data != null){
|
|
686
|
+
if (data != null) {
|
|
717
687
|
String url = "";
|
|
718
688
|
String payload = (String) data.getJSONObject(0).get("pushPayload");
|
|
719
689
|
JSONObject object = new JSONObject(payload);
|
|
@@ -735,7 +705,6 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
735
705
|
@Override
|
|
736
706
|
public void run() {
|
|
737
707
|
try {
|
|
738
|
-
System.out.println("testing send notification "+bundle);
|
|
739
708
|
if (callbackContext != null) {
|
|
740
709
|
String pushPaylaod = bundle.getString("ai_content");
|
|
741
710
|
PluginResult result = new PluginResult(PluginResult.Status.OK, pushPaylaod);
|
|
@@ -749,6 +718,7 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
749
718
|
}).start();
|
|
750
719
|
}
|
|
751
720
|
|
|
721
|
+
|
|
752
722
|
//==================================
|
|
753
723
|
// SESSION SETTING APIS
|
|
754
724
|
//==================================
|
|
@@ -974,7 +944,7 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
974
944
|
|
|
975
945
|
callbackContext.success();
|
|
976
946
|
} catch (Throwable e) {
|
|
977
|
-
Log.e(TAG, "trackScreens run: error ", e
|
|
947
|
+
Log.e(TAG, "trackScreens run: error ", e);
|
|
978
948
|
}
|
|
979
949
|
}
|
|
980
950
|
}).start();
|
|
@@ -982,4 +952,41 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
982
952
|
callbackContext.error(e.getMessage());
|
|
983
953
|
}
|
|
984
954
|
}
|
|
955
|
+
|
|
956
|
+
public static void storeTempData(String key, String value, Context context) {
|
|
957
|
+
try {
|
|
958
|
+
SharedPreferences sp = context.getSharedPreferences(TEMP_DB,
|
|
959
|
+
Context.MODE_PRIVATE);
|
|
960
|
+
SharedPreferences.Editor edit = sp.edit();
|
|
961
|
+
edit.putString(key, value);
|
|
962
|
+
edit.apply();
|
|
963
|
+
} catch (Throwable e) {
|
|
964
|
+
Log.e(TAG, "storeTempData: error ", e);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
public static void resetTempData(String key, Context context) {
|
|
969
|
+
try {
|
|
970
|
+
SharedPreferences sp = context.getSharedPreferences(TEMP_DB,
|
|
971
|
+
Context.MODE_PRIVATE);
|
|
972
|
+
SharedPreferences.Editor edit = sp.edit();
|
|
973
|
+
edit.remove(key);
|
|
974
|
+
edit.apply();
|
|
975
|
+
} catch (Throwable e) {
|
|
976
|
+
Log.e(TAG, "resetTempData: error ", e);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
public static String loadTempData(String key, Context ctx) {
|
|
982
|
+
String name = "";
|
|
983
|
+
try {
|
|
984
|
+
SharedPreferences sp = ctx.getSharedPreferences(TEMP_DB,
|
|
985
|
+
Context.MODE_PRIVATE);
|
|
986
|
+
name = sp.getString(key, "");
|
|
987
|
+
} catch (Throwable e) {
|
|
988
|
+
Log.e(TAG, "loadTempData: error ", e);
|
|
989
|
+
}
|
|
990
|
+
return name;
|
|
991
|
+
}
|
|
985
992
|
}
|
|
@@ -88,7 +88,7 @@ public class AppICEPushHandler {
|
|
|
88
88
|
bundle.putString(PUSH_PAYLOAD, message);
|
|
89
89
|
clickIntent.putExtras(bundle);
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
// Utility.sendEventToListener(mContext, newIntent);
|
|
92
92
|
return PendingIntent.getActivity(
|
|
93
93
|
mContext, 1, clickIntent, getPendingIntentFlags());
|
|
94
94
|
} catch (Throwable e) {
|
package/src/ios/AppICEPlugin.h
CHANGED
|
@@ -89,5 +89,8 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
|
|
|
89
89
|
-(void)pushNotificationClicked:(CDVInvokedUrlCommand *)command;
|
|
90
90
|
-(void)getDeepLinkURL:(CDVInvokedUrlCommand *)command;
|
|
91
91
|
|
|
92
|
+
//new empty function
|
|
93
|
+
-(void)isDeviceReady:(CDVInvokedUrlCommand *)command;
|
|
94
|
+
|
|
92
95
|
@end
|
|
93
96
|
|
package/src/ios/AppICEPlugin.m
CHANGED
|
@@ -158,40 +158,23 @@ static NSInteger const kNotificationStackSize = 10;
|
|
|
158
158
|
-(void)onHandleNotificationUResponse:(NSDictionary *)userInfo {
|
|
159
159
|
@try {
|
|
160
160
|
NSLog(@"appice - uresponse : %@",userInfo);
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
|
|
162
|
+
|
|
163
163
|
|
|
164
164
|
if (userInfo != nil && userInfo.count >0){
|
|
165
|
-
NSLog(@"appice - getDeepLinkURL : %@", userInfo);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if ([userInfo valueForKeyPath:@"data.message.cdata.eurl"]) {
|
|
169
|
-
// Extract the 'eurl' key from 'cdataDictionary'
|
|
170
|
-
deepLinkurl = [userInfo valueForKeyPath:@"data.message.cdata.eurl"];
|
|
171
|
-
}
|
|
172
|
-
else
|
|
173
|
-
{
|
|
174
|
-
// If 'user' is still empty, attempt to extract 'eurl' directly from the payload
|
|
175
|
-
if([userInfo valueForKeyPath:@"data.message.eurl"])
|
|
176
|
-
{
|
|
177
|
-
deepLinkurl = [userInfo valueForKeyPath:@"data.message.eurl"];
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
165
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
166
|
+
[[appICE sharedInstance]handleClickOnPush:userInfo OpenDeepLink:YES];
|
|
167
|
+
|
|
168
|
+
NSDictionary *pushPayload = [userInfo valueForKeyPath:@"data.message"];
|
|
169
|
+
NSData *payloadData = [NSJSONSerialization dataWithJSONObject:pushPayload
|
|
170
|
+
options:kNilOptions
|
|
171
|
+
error:nil];
|
|
172
|
+
NSString *payloadString = [[NSString alloc] initWithData:payloadData encoding:NSUTF8StringEncoding];
|
|
173
|
+
NSLog(@"payloadString string: %@", payloadString);
|
|
174
|
+
|
|
175
|
+
NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
|
|
184
176
|
[self.commandDelegate evalJs:js];
|
|
185
177
|
}
|
|
186
|
-
NSDictionary *pushPayload = [userInfo valueForKeyPath:@"data.message"];
|
|
187
|
-
NSData *payloadData = [NSJSONSerialization dataWithJSONObject:pushPayload
|
|
188
|
-
options:kNilOptions
|
|
189
|
-
error:nil];
|
|
190
|
-
NSString *payloadString = [[NSString alloc] initWithData:payloadData encoding:NSUTF8StringEncoding];
|
|
191
|
-
NSLog(@"payloadString string: %@", payloadString);
|
|
192
|
-
|
|
193
|
-
NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
|
|
194
|
-
[self.commandDelegate evalJs:js];
|
|
195
178
|
|
|
196
179
|
} @catch (NSException *exception) {
|
|
197
180
|
NSLog(@"appice - uresponse : %@",exception.description);
|
|
@@ -1101,6 +1084,12 @@ static NSInteger const kNotificationStackSize = 10;
|
|
|
1101
1084
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1102
1085
|
}
|
|
1103
1086
|
|
|
1087
|
+
// new empty function
|
|
1088
|
+
-(void)isDeviceReady:(CDVInvokedUrlCommand *)command {
|
|
1089
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1090
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1104
1093
|
@end
|
|
1105
1094
|
|
|
1106
1095
|
|
package/www/AppICE.js
CHANGED
|
@@ -67,6 +67,10 @@ cordova.define("cordova-plugin-appice.AppICE", function (require, exports, modul
|
|
|
67
67
|
cordova.exec(success, error, "AppICEPlugin", "registerLifeCycle", []);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
AppICE.prototype.isDeviceReady = function (success, error) {
|
|
71
|
+
cordova.exec(success, error, "AppICEPlugin", "isDeviceReady", []);
|
|
72
|
+
};
|
|
73
|
+
|
|
70
74
|
//==================================
|
|
71
75
|
// PLAY STORE SETTING APIS
|
|
72
76
|
//==================================
|
|
@@ -213,27 +217,42 @@ cordova.define("cordova-plugin-appice.AppICE", function (require, exports, modul
|
|
|
213
217
|
|
|
214
218
|
AppICE.prototype.getDataForKey = function (payload, key, success, error) {
|
|
215
219
|
try {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
220
|
+
let parsedPayload;
|
|
221
|
+
|
|
222
|
+
// if payload is a string
|
|
223
|
+
if (typeof payload === 'string') {
|
|
224
|
+
// Parse the payload string to JSON
|
|
225
|
+
parsedPayload = JSON.parse(payload);
|
|
226
|
+
} else {
|
|
227
|
+
// if already an object
|
|
228
|
+
parsedPayload = payload;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// if key exist then return the value
|
|
232
|
+
if (parsedPayload.hasOwnProperty(key)) {
|
|
233
|
+
success(parsedPayload[key]);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// check for active camps in case of who + what payload
|
|
237
|
+
if (parsedPayload.hasOwnProperty('activeCampaigns') && parsedPayload.activeCampaigns.length > 0) {
|
|
238
|
+
const data = parsedPayload.activeCampaigns[0].data;
|
|
239
|
+
if (data && data.hasOwnProperty(key)) {
|
|
240
|
+
success(data[key]);
|
|
241
|
+
}
|
|
242
|
+
// activeCamps => cdata
|
|
243
|
+
if (data && data.hasOwnProperty('cdata') && data.cdata.hasOwnProperty(key)) {
|
|
244
|
+
success(data.cdata[key]);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (parsedPayload.hasOwnProperty('cdata') && parsedPayload.cdata.hasOwnProperty(key)) {
|
|
249
|
+
success(parsedPayload.cdata[key]);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
error('something is wrong please try again with valid data');
|
|
253
|
+
} catch (errMessage) {
|
|
254
|
+
error(errMessage)
|
|
235
255
|
}
|
|
236
|
-
|
|
237
256
|
};
|
|
238
257
|
|
|
239
258
|
//===============================
|