cordova-plugin-appice 2.1.7 → 2.1.8
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
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
-
id="cordova-plugin-appice" version="2.1.
|
|
3
|
+
id="cordova-plugin-appice" version="2.1.8">
|
|
4
4
|
<name>AppICE</name>
|
|
5
5
|
<description>AppICE Plugin for Cordova/PhoneGap</description>
|
|
6
6
|
<license>Commercial</license>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
<preference name="WORK_MANAGER_VERSION" default="2.7.1"/>
|
|
115
115
|
|
|
116
116
|
<!-- AppICE VERSION-->
|
|
117
|
-
<preference name="APPICE_VERSION" default="2.5.
|
|
117
|
+
<preference name="APPICE_VERSION" default="2.5.88"/>
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
<!-- USES PERMISSION -->
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.appice.cordova;
|
|
2
2
|
|
|
3
|
+
import static com.appice.cordova.AppICEPushHandler.handleLandingPage;
|
|
4
|
+
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
import android.content.Intent;
|
|
5
7
|
import android.content.SharedPreferences;
|
|
@@ -34,8 +36,8 @@ import semusi.activitysdk.Api;
|
|
|
34
36
|
import semusi.activitysdk.ContextData;
|
|
35
37
|
import semusi.activitysdk.ContextSdk;
|
|
36
38
|
import semusi.activitysdk.SdkConfig;
|
|
37
|
-
import semusi.activitysdk.User;
|
|
38
39
|
import semusi.context.utility.Utility;
|
|
40
|
+
import semusi.model.user.User;
|
|
39
41
|
|
|
40
42
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
41
43
|
|
|
@@ -115,20 +117,24 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
115
117
|
boolean isPushNotification = (payload != null && payload.length() > 0) ? true : false;
|
|
116
118
|
if (isPushNotification) {
|
|
117
119
|
JSONObject data = new JSONObject(payload);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
webView.getView().post(new Runnable() {
|
|
123
|
-
@Override
|
|
124
|
-
public void run() {
|
|
125
|
-
webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + json + ");");
|
|
126
|
-
}
|
|
127
|
-
});
|
|
120
|
+
String notificationType = data.optString("et");
|
|
121
|
+
if (Utility.isValidObject(notificationType) && notificationType.equalsIgnoreCase("lp")) {
|
|
122
|
+
String url = data.optString("eurl");
|
|
123
|
+
handleLandingPage(url, cordova.getActivity().getApplicationContext());
|
|
128
124
|
} else {
|
|
129
|
-
|
|
125
|
+
final String json = "{'payload':" + data.toString() + "}";
|
|
126
|
+
System.out.println("AppICE : onNewIntent : json " + json);
|
|
127
|
+
if (statusFlag) {
|
|
128
|
+
webView.getView().post(new Runnable() {
|
|
129
|
+
@Override
|
|
130
|
+
public void run() {
|
|
131
|
+
webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + json + ");");
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
storeTempData(CALLBACK_CONSTANTS, json, cordova.getActivity());
|
|
136
|
+
}
|
|
130
137
|
}
|
|
131
|
-
|
|
132
138
|
ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
|
|
133
139
|
}
|
|
134
140
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
package com.appice.cordova;
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
3
4
|
import android.app.PendingIntent;
|
|
5
|
+
import android.content.ComponentName;
|
|
4
6
|
import android.content.Context;
|
|
5
7
|
import android.content.Intent;
|
|
6
8
|
import android.content.pm.PackageManager;
|
|
7
9
|
import android.content.pm.ResolveInfo;
|
|
10
|
+
import android.net.Uri;
|
|
8
11
|
import android.os.Build;
|
|
9
12
|
import android.os.Bundle;
|
|
10
13
|
import android.util.Log;
|
|
11
14
|
|
|
12
15
|
import androidx.annotation.NonNull;
|
|
13
16
|
|
|
17
|
+
import com.appice.sample.MainActivity;
|
|
14
18
|
import com.google.firebase.messaging.RemoteMessage;
|
|
15
19
|
|
|
16
|
-
import org.json.JSONObject;
|
|
17
|
-
|
|
18
|
-
import java.util.List;
|
|
19
20
|
import java.util.Map;
|
|
20
21
|
|
|
21
22
|
import semusi.activitysdk.ContextSdk;
|
|
22
|
-
import semusi.context.utility.Utility;
|
|
23
23
|
|
|
24
24
|
/* import path for MainActivity */
|
|
25
25
|
|
|
@@ -31,17 +31,22 @@ public class AppICEPushHandler {
|
|
|
31
31
|
private static final String ACTION = "com.appice.campaignEvent";
|
|
32
32
|
private static final String PUSH_PAYLOAD = "ai_content";
|
|
33
33
|
private static final String MESSAGE = "message";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
public static Class<?> getActivityClass(Context context){
|
|
36
|
+
Class<?> launcherActivity = getLauncherActivityClass(context);
|
|
37
|
+
if (launcherActivity == null){
|
|
38
|
+
// please import and use your launch activity here and uncomment the below line
|
|
39
|
+
// launcherActivity = MainActivity.class;
|
|
40
|
+
}
|
|
41
|
+
return launcherActivity;
|
|
42
|
+
}
|
|
37
43
|
|
|
38
44
|
public void onMessageReceived(RemoteMessage message, Context context) {
|
|
39
45
|
Map<String, String> data = message.getData();
|
|
40
46
|
|
|
41
|
-
if (isAppICEPush(message)
|
|
47
|
+
if (isAppICEPush(message) ) {
|
|
48
|
+
System.out.println("data coming "+message.getData());
|
|
42
49
|
ContextSdk.handleAppICEPush(message, createPendingIntent(data.get(MESSAGE), context), deletePendingIntent(context), context);
|
|
43
|
-
} else if (isAppICEPush(message) && checkIfPayloadHaveExternalUrl(message)) {
|
|
44
|
-
ContextSdk.handleAppICEPush(message, context);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
|
@@ -70,25 +75,19 @@ public class AppICEPushHandler {
|
|
|
70
75
|
//================================
|
|
71
76
|
private static PendingIntent internalCreatePendingIntent(String message, Context mContext) {
|
|
72
77
|
try {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// please use your launch activity here for example
|
|
76
|
-
// launcherActivityClass = MainActivity.class;
|
|
77
|
-
}
|
|
78
|
-
Intent clickIntent = new Intent(mContext, launcherActivityClass);
|
|
78
|
+
int code = (int) System.currentTimeMillis();
|
|
79
|
+
Intent clickIntent = new Intent(mContext, getActivityClass(mContext));
|
|
79
80
|
Bundle bundle = new Bundle();
|
|
80
81
|
final Intent newIntent = new Intent();
|
|
81
|
-
newIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
82
82
|
newIntent.setAction(ACTION);
|
|
83
|
-
clickIntent.addFlags(Intent.
|
|
84
|
-
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
83
|
+
clickIntent.addFlags( Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
85
84
|
newIntent.putExtra(PUSH_PAYLOAD, message);
|
|
86
85
|
bundle.putString(PUSH_PAYLOAD, message);
|
|
87
86
|
clickIntent.putExtras(bundle);
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
// Utility.sendEventToListener(mContext, newIntent);
|
|
90
89
|
return PendingIntent.getActivity(
|
|
91
|
-
mContext,
|
|
90
|
+
mContext, code, clickIntent, getPendingIntentFlags());
|
|
92
91
|
} catch (Throwable e) {
|
|
93
92
|
Log.e(TAG, "createPendingIntent: error ", e);
|
|
94
93
|
}
|
|
@@ -97,10 +96,15 @@ public class AppICEPushHandler {
|
|
|
97
96
|
|
|
98
97
|
public static PendingIntent internalDeletePendingIntent(Context mContext) {
|
|
99
98
|
try {
|
|
100
|
-
|
|
101
|
-
Intent clickIntent = new Intent(mContext,
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
int code = (int) System.currentTimeMillis();
|
|
100
|
+
Intent clickIntent = new Intent(mContext, getActivityClass(mContext));
|
|
101
|
+
Bundle bundle = new Bundle();
|
|
102
|
+
bundle.putBoolean("delete", true);
|
|
103
|
+
clickIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); // Use NEW_TASK to isolate tasks
|
|
104
|
+
clickIntent.putExtras(bundle);
|
|
105
|
+
|
|
106
|
+
return PendingIntent.getBroadcast(mContext, code, clickIntent,
|
|
107
|
+
getPendingIntentFlags()| PendingIntent.FLAG_ONE_SHOT);
|
|
104
108
|
} catch (Throwable t) {
|
|
105
109
|
Log.e(TAG, "deletePendingIntent: error ", t);
|
|
106
110
|
}
|
|
@@ -118,44 +122,42 @@ public class AppICEPushHandler {
|
|
|
118
122
|
return flag;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
private boolean checkIfPayloadHaveExternalUrl(RemoteMessage message) {
|
|
122
|
-
Map<String, String> map = message.getData();
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
if (map != null) {
|
|
126
|
-
String messageStr = map.get(MESSAGE);
|
|
127
|
-
if (messageStr != null && messageStr.length() > 0) {
|
|
128
|
-
JSONObject messageObj = new JSONObject(messageStr);
|
|
129
|
-
String type = messageObj.optString(EXTERNAL_TYPE);
|
|
130
|
-
if (type.equalsIgnoreCase(DEEPLINK)) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
if (type.equalsIgnoreCase(LANDING_PAGE)) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} catch (Throwable t) {
|
|
139
|
-
Log.e(TAG, "checkIfPayloadHaveExternalUrl: error ", t);
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
125
|
private static Class<?> getLauncherActivityClass(Context context) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
126
|
+
// Get the launcher activity name dynamically
|
|
127
|
+
PackageManager pm = context.getPackageManager();
|
|
128
|
+
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
|
|
129
|
+
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
|
130
|
+
launchIntent.setPackage(context.getPackageName());
|
|
131
|
+
|
|
132
|
+
ResolveInfo resolveInfo = pm.resolveActivity(launchIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
149
133
|
|
|
150
134
|
if (resolveInfo != null && resolveInfo.activityInfo != null) {
|
|
151
|
-
String
|
|
135
|
+
String launcherActivityName = resolveInfo.activityInfo.name;
|
|
152
136
|
try {
|
|
153
|
-
return Class.forName(
|
|
137
|
+
return Class.forName(launcherActivityName);
|
|
154
138
|
} catch (Throwable e) {
|
|
155
|
-
|
|
139
|
+
System.out.println("getLauncherActivityClass: error "+e);
|
|
156
140
|
}
|
|
141
|
+
} else {
|
|
142
|
+
System.out.println("Launcher activity not found.");
|
|
157
143
|
}
|
|
158
|
-
|
|
159
144
|
return null;
|
|
160
145
|
}
|
|
146
|
+
|
|
147
|
+
public static void handleLandingPage(String url, Context context){
|
|
148
|
+
try {
|
|
149
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
150
|
+
url = "https://" + url;
|
|
151
|
+
}
|
|
152
|
+
} catch (Throwable e) {
|
|
153
|
+
System.out.println("handleLandingPage check if any error with prefix "+e);
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
157
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
158
|
+
context.startActivity(intent);
|
|
159
|
+
} catch (Throwable e) {
|
|
160
|
+
System.out.println("handleLandingPage check if any error with intent "+e);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
161
163
|
}
|
package/www/AppICE.js
CHANGED
|
@@ -249,7 +249,7 @@ cordova.define("cordova-plugin-appice.AppICE", function (require, exports, modul
|
|
|
249
249
|
success(parsedPayload.cdata[key]);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
// error('something is wrong please try again with valid data');
|
|
253
253
|
} catch (errMessage) {
|
|
254
254
|
error(errMessage)
|
|
255
255
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$">
|
|
6
|
-
<sourceFolder url="file://$MODULE_DIR$/android" isTestSource="false" packagePrefix="org.apache.cordova.firebase" />
|
|
7
|
-
</content>
|
|
8
|
-
<orderEntry type="inheritedJdk" />
|
|
9
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
-
</component>
|
|
11
|
-
</module>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$">
|
|
6
|
-
<sourceFolder url="file://$MODULE_DIR$/android" isTestSource="false" packagePrefix="org.apache.cordova.firebase" />
|
|
7
|
-
</content>
|
|
8
|
-
<orderEntry type="inheritedJdk" />
|
|
9
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
-
</component>
|
|
11
|
-
</module>
|