cordova-plugin-appice 2.1.7 → 2.1.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-appice",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "AppICE Plugin for Cordova/PhoneGap",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-appice",
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.7">
3
+ id="cordova-plugin-appice" version="2.1.9">
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.87"/>
117
+ <preference name="APPICE_VERSION" default="2.5.88"/>
118
118
 
119
119
 
120
120
  <!-- USES PERMISSION -->
@@ -16,34 +16,6 @@ module.exports = function (context) {
16
16
  var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
17
17
  var project_properties = path.join(platformRoot, 'project.properties');
18
18
 
19
- console.log("platformPreference : " + APPICE_FIREBASE_UPDATE);
20
- if (APPICE_FIREBASE_UPDATE === "true") {
21
- console.log("else true APPICE_FIREBASE_UPDATE : " + APPICE_FIREBASE_UPDATE);
22
- var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
23
- if (fs.existsSync(firebaseFile1)) {
24
- try {
25
- shell.rm('-Rf', firebaseFile1);
26
- } catch (err) {
27
- }
28
- }
29
-
30
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/android/FirebasePluginMessagingService.java');
31
- try {
32
- shell.cp('-f', modifiedFile1, firebaseFile1);
33
- } catch (err) {
34
- }
35
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
36
- if (fs.existsSync(firebaseFile2)) {
37
- try {
38
- shell.rm('-Rf', firebaseFile2);
39
- } catch (err) {
40
- }
41
- }
42
- try {
43
- shell.cp('-f', modifiedFile1, firebaseFile2);
44
- } catch (err) {
45
- }
46
- }
47
19
  //////
48
20
  var platformwww1 = path.join(platformRoot, '/platform_www/plugins/cordova-plugin-appice/www/AppICE.js');
49
21
  var platformwww2 = path.join(pluginsAppiceRoot, '/www/AppICE.js');
@@ -20,33 +20,6 @@ module.exports = function (context) {
20
20
  var project_properties = path.join(platformRoot, 'project.properties');
21
21
  var build_gradle = path.join(platformRoot, '/app/build.gradle');
22
22
 
23
- var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
24
- if (fs.existsSync(firebaseFile1)) {
25
- try {
26
- shell.rm('-Rf', firebaseFile1);
27
- } catch (err) {
28
- }
29
- }
30
-
31
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/android/FirebasePluginMessagingService.java');
32
- try {
33
- shell.cp('-f', modifiedFile1, firebaseFile1);
34
- } catch (err) {
35
- }
36
-
37
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
38
- if (fs.existsSync(firebaseFile2)) {
39
- try {
40
- shell.rm('-Rf', firebaseFile2);
41
- } catch (err) {
42
- }
43
- }
44
-
45
- try {
46
- shell.cp('-f', modifiedFile1, firebaseFile2);
47
- } catch (err) {
48
- }
49
-
50
23
  var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
51
24
  if (fs.existsSync(manifestFile)) {
52
25
  try {
@@ -23,35 +23,6 @@ module.exports = function (context) {
23
23
  var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "ios");
24
24
 
25
25
  ////SSL_PINNING
26
-
27
- if (APPICE_FIREBASE_UPDATE === "true") {
28
- console.log("inside APPICE_FIREBASE_UPDATE : " + appName);
29
- var firebaseFile1 = path.join(platformRoot, '/' + appName + '/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m');
30
- if (fs.existsSync(firebaseFile1)) {
31
- try {
32
- shell.rm('-Rf', firebaseFile1);
33
- } catch (err) {
34
- }
35
- }
36
-
37
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/ios/AppDelegate+FirebasePlugin.m');
38
- try {
39
- shell.cp('-f', modifiedFile1, firebaseFile1);
40
- } catch (err) {
41
- }
42
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
43
- if (fs.existsSync(firebaseFile2)) {
44
- try {
45
- shell.rm('-Rf', firebaseFile2);
46
- } catch (err) {
47
- }
48
- }
49
- try {
50
- shell.cp('-f', modifiedFile1, firebaseFile2);
51
- } catch (err) {
52
- }
53
-
54
- }
55
26
  if (SSL_PINNING === "true") {
56
27
  console.log("appName : " + appName);
57
28
  var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
@@ -17,33 +17,6 @@ module.exports = function (context) {
17
17
  var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "ios");
18
18
  var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "ios");
19
19
 
20
- var firebaseFile1 = path.join(platformRoot, '/' + appName + '/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m');
21
- if (fs.existsSync(firebaseFile1)) {
22
- try {
23
- shell.rm('-Rf', firebaseFile1);
24
- } catch (err) {
25
- }
26
- }
27
-
28
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/ios/AppDelegate+FirebasePlugin.m');
29
- try {
30
- shell.cp('-f', modifiedFile1, firebaseFile1);
31
- } catch (err) {
32
- }
33
-
34
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
35
- if (fs.existsSync(firebaseFile2)) {
36
- try {
37
- shell.rm('-Rf', firebaseFile2);
38
- } catch (err) {
39
- }
40
- }
41
-
42
- try {
43
- shell.cp('-f', modifiedFile1, firebaseFile2);
44
- } catch (err) {
45
- }
46
-
47
20
  if (SSL_PINNING === "true") {
48
21
  console.log("appName : " + appName);
49
22
  var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
@@ -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
- final String json = "{'payload':" + data.toString() + "}";
120
- System.out.println("AppICE : onNewIntent : json " + json);
121
- if (statusFlag) {
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
- storeTempData(CALLBACK_CONSTANTS, json, cordova.getActivity());
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
- private static final String EXTERNAL_TYPE = "et";
35
- private static final String DEEPLINK = "dl";
36
- private static final String LANDING_PAGE = "lp";
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) && !checkIfPayloadHaveExternalUrl(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
- Class<?> launcherActivityClass = getLauncherActivityClass(mContext);
74
- if (launcherActivityClass == null) {
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.FLAG_ACTIVITY_NEW_TASK
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
- // Utility.sendEventToListener(mContext, newIntent);
88
+ // Utility.sendEventToListener(mContext, newIntent);
90
89
  return PendingIntent.getActivity(
91
- mContext, 1, clickIntent, getPendingIntentFlags());
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
- // please use your launch activity here
101
- Intent clickIntent = new Intent(mContext, CampaignCampsReceiver.class);
102
- return PendingIntent.getBroadcast(mContext, 1, clickIntent,
103
- getPendingIntentFlags());
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
- PackageManager packageManager = context.getPackageManager();
146
- Intent intent = new Intent(Intent.ACTION_MAIN);
147
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
148
- ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
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 className = resolveInfo.activityInfo.name;
135
+ String launcherActivityName = resolveInfo.activityInfo.name;
152
136
  try {
153
- return Class.forName(className);
137
+ return Class.forName(launcherActivityName);
154
138
  } catch (Throwable e) {
155
- Log.e(TAG, "getLauncherActivityClass: error ", e);
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
- error('something is wrong please try again with valid data');
252
+ // error('something is wrong please try again with valid data');
253
253
  } catch (errMessage) {
254
254
  error(errMessage)
255
255
  }