cordova-plugin-appice 2.1.8 → 2.2.0

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.
@@ -23,12 +23,13 @@ function alertDismissed() {
23
23
 
24
24
  function onDeviceReady() {
25
25
  // Cordova is now initialized. Have fun!
26
-
26
+ onResume()
27
27
  console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
28
28
  document.getElementById('deviceready').classList.add('ready');
29
29
  document.addEventListener('pushNotificationClicked', e => { testing(e.notification, "notificationCallback") })
30
30
  document.addEventListener('pushNotificationClicked', pushNotificationClicked);
31
31
  initializesdk()
32
+
32
33
  }
33
34
  function pushNotificationClicked(payload, type) {
34
35
  console.log('in testing method');
@@ -41,6 +42,34 @@ function pushNotificationClicked(payload, type) {
41
42
 
42
43
  });
43
44
  }
45
+
46
+ //isDeviceReady
47
+ document.addEventListener('resume', onResume, false);
48
+ // Function to handle app resuming to foreground
49
+ function onResume() {
50
+ console.log('Deeplink Push : App is now in the foreground');
51
+ // Handle tasks needed when app comes back to the foreground
52
+ AppICE.isDeviceReady(true,
53
+ function(success) {
54
+ console.log('Deeplink Push STATE 4: App is active, isDeviceReady success:', success);
55
+ },
56
+ function(error) { console.log('Deeplink Push STATE 4: App is active, isDeviceReady error:', error); }
57
+ );
58
+
59
+ }
60
+
61
+ document.addEventListener('pause', onPause, false);
62
+ // Function to handle app going to background
63
+ function onPause() {
64
+ console.log('Deeplink Push : App is now in the background');
65
+ // Here you can handle any tasks needed when app goes to the background
66
+ AppICE.isDeviceReady(false,
67
+ function(success) { console.log('Deeplink Push : App is inactive, isDeviceReady success:', success); },
68
+ function(error) { console.log('Deeplink Push : App is inactive, isDeviceReady error:', error); }
69
+ );
70
+ }
71
+
72
+
44
73
  // initialize appice sdk
45
74
  document.getElementById("initsdk").addEventListener("click", initializesdk);
46
75
  function initializesdk() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-appice",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
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.8">
3
+ id="cordova-plugin-appice" version="2.2.0">
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.88"/>
117
+ <preference name="APPICE_VERSION" default="2.5.90"/>
118
118
 
119
119
 
120
120
  <!-- USES PERMISSION -->
@@ -126,14 +126,18 @@
126
126
  <config-file target="AndroidManifest.xml" parent="/manifest/application">
127
127
  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
128
128
 
129
- <service android:name="semusi.activitysdk.Api" android:exported="false" android:protectionLevel="signature"/>
129
+ <service android:name="semusi.activitysdk.Api"
130
+ android:exported="false" android:protectionLevel="signature"/>
130
131
 
131
- <receiver android:name="com.appice.cordova.CampaignCampsReceiver" android:exported="false" android:protectionLevel="signature">
132
+ <receiver android:name="com.appice.cordova.CampaignCampsReceiver"
133
+ android:exported="false" android:protectionLevel="signature">
132
134
  <intent-filter>
133
135
  <action android:name="com.appice.campaignEvent" />
134
136
  </intent-filter>
135
137
  </receiver>
136
- <service android:name="com.appice.cordova.NotificationEventService" android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE">
138
+ <service android:name="com.appice.cordova.NotificationEventService"
139
+ android:protectionLevel="signature"
140
+ android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE">
137
141
  <intent-filter>
138
142
  <action android:name="com.appice.campaignEvent" />
139
143
  </intent-filter>
@@ -141,7 +145,8 @@
141
145
 
142
146
  <activity android:name="semusi.context.ui.UIEventsHandler" android:exported="false" android:protectionLevel="signature" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
143
147
 
144
- <activity android:name="semusi.context.ui.AppICENotifUI" android:exported="false">
148
+ <activity android:name="semusi.context.ui.AppICENotifUI"
149
+ android:protectionLevel="signature" android:exported="false">
145
150
  <intent-filter>
146
151
  <action android:name="AppICE.Notification.FCM_Action"/>
147
152
  <category android:name="android.intent.category.DEFAULT"/>
@@ -157,13 +162,17 @@
157
162
  </intent-filter>
158
163
  </activity>
159
164
 
160
- <service android:name="semusi.ruleengine.pushmanager.SdkFcmListenerService" android:exported="false" android:protectionLevel="signature">
165
+ <service android:name="semusi.ruleengine.pushmanager.SdkFcmListenerService"
166
+ android:exported="false" android:protectionLevel="signature">
161
167
  <intent-filter>
162
168
  <action android:name="com.google.firebase.MESSAGING_EVENT"/>
163
169
  </intent-filter>
164
170
  </service>
165
171
 
166
- <service android:exported="false" android:name="semusi.ruleengine.pushmanager.NotificationEventService" android:permission="android.permission.BIND_JOB_SERVICE">
172
+ <service android:exported="false"
173
+ android:protectionLevel="signature"
174
+ android:name="semusi.ruleengine.pushmanager.NotificationEventService"
175
+ android:permission="android.permission.BIND_JOB_SERVICE">
167
176
  </service>
168
177
  </config-file>
169
178
 
@@ -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');
@@ -14,7 +14,6 @@ import android.util.Log;
14
14
 
15
15
  import androidx.annotation.NonNull;
16
16
 
17
- import com.appice.sample.MainActivity;
18
17
  import com.google.firebase.messaging.RemoteMessage;
19
18
 
20
19
  import java.util.Map;
@@ -198,10 +198,10 @@ static OriginalImpType originalImp;
198
198
 
199
199
  @try {
200
200
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
201
- [NSThread sleepForTimeInterval:2.0f];
201
+ //[NSThread sleepForTimeInterval:2.0f];
202
202
  dispatch_async(dispatch_get_main_queue(), ^{
203
203
  NSDictionary *userInfo = response.notification.request.content.userInfo;
204
- NSLog(@"inside swizzledidresponse %@",userInfo);
204
+ NSLog(@"Deeplink Push : STATE 1 inside swizzledidresponse %@",userInfo);
205
205
  BOOL appIceServer = [[appICE sharedInstance] isAppICENotification:userInfo];
206
206
  if(appIceServer)
207
207
  {
@@ -33,6 +33,9 @@ static NSInteger const kNotificationStackSize = 10;
33
33
  @synthesize notificationCallbackId; // Manages the callback ID for notifications.
34
34
  @synthesize notificationStack; // Stack to hold pending notifications.
35
35
 
36
+ static BOOL isAppInitialized = NO;
37
+ static NSDictionary *pendingDeeplink = nil;
38
+
36
39
 
37
40
 
38
41
  +(void)load {
@@ -158,30 +161,27 @@ static NSInteger const kNotificationStackSize = 10;
158
161
  -(void)onHandleNotificationUResponse:(NSDictionary *)userInfo {
159
162
  @try {
160
163
  NSLog(@"appice - uresponse : %@",userInfo);
161
-
162
-
163
-
164
+
164
165
  if (userInfo != nil && userInfo.count >0){
165
-
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
166
 
175
- NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
176
- [self.commandDelegate evalJs:js];
167
+ if (!isAppInitialized) {
168
+ NSLog(@"Deeplink Push : STATE 2 App not initialized, storing deeplink for later processing");
169
+ [self storePendingDeeplink: userInfo];
170
+ } else {
171
+ NSLog(@"Deeplink Push :STATE 2 App is initialized storePendingDeeplin and processPendingDeeplink deeplink immediately");
172
+ [self storePendingDeeplink:userInfo];
173
+ [self processPendingDeeplink];
174
+ }
175
+
177
176
  }
178
-
177
+
179
178
  } @catch (NSException *exception) {
180
- NSLog(@"appice - uresponse : %@",exception.description);
179
+ NSLog(@"appice - uresponse exception : %@",exception.description);
181
180
  } @finally {
182
181
 
183
182
  }
184
183
  }
184
+
185
185
  -(id)sendRequestWithURL:(NSString*)url withPostData:(NSString*)post postType:(BOOL)type {
186
186
  return [self initWithURL:url withPostData:post withPostType:type];
187
187
  }
@@ -1084,12 +1084,87 @@ static NSInteger const kNotificationStackSize = 10;
1084
1084
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
1085
1085
  }
1086
1086
 
1087
- // new empty function
1088
- -(void)isDeviceReady:(CDVInvokedUrlCommand *)command {
1089
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1087
+ /*----------------------------------------------------------------------------
1088
+ isDeviceReady
1089
+ * Check if App is Ready and process the pending deeplink
1090
+ -----------------------------------------------------------------------------*/
1091
+ - (void)isDeviceReady:(CDVInvokedUrlCommand *)command {
1092
+ NSLog(@"Deeplink Push : STATE 3 processPendingDeeplink command %@", command);
1093
+
1094
+ CDVPluginResult *pluginResult;
1095
+
1096
+ // Check if the arguments array contains a valid boolean
1097
+ if (command.arguments.count > 0 && [command.arguments[0] isKindOfClass:[NSNumber class]]) {
1098
+ BOOL isActive = [command.arguments[0] boolValue];
1099
+ NSLog(@"Deeplink Push : isDeviceReady called with isActive: %d", isActive);
1100
+
1101
+ if (isActive) {
1102
+ // Perform actions for active state
1103
+ isAppInitialized = YES;
1104
+ [self processPendingDeeplink];
1105
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Device is active"];
1106
+ } else {
1107
+ // Perform actions for inactive state
1108
+ isAppInitialized = NO;
1109
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Device is inactive"];
1110
+ }
1111
+ } else {
1112
+ NSLog(@"Deeplink Push : isDeviceReady called with no arguments or invalid argument type");
1113
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No valid argument provided"];
1114
+ }
1115
+
1090
1116
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
1091
1117
  }
1092
1118
 
1119
+
1120
+ // Method to handle pending deeplink once app is initialized
1121
+ - (void)processPendingDeeplink {
1122
+ @try {
1123
+ NSLog(@"Deeplink Push STATE 4: processPendingDeeplink called, isAppInitialized: %d, pendingDeeplink: %@", isAppInitialized, pendingDeeplink);
1124
+ if (isAppInitialized && pendingDeeplink) {
1125
+ NSLog(@"Deeplink Push : STATE 4 handled stored data");
1126
+ [[appICE sharedInstance] handleClickOnPush:userInfo OpenDeepLink:YES];
1127
+ [self eventClickedPayload:pendingDeeplink];
1128
+
1129
+ pendingDeeplink = nil;
1130
+ }
1131
+ } @catch (NSException *exception) {
1132
+ NSLog(@"Deeplink Push : processPendingDeeplink exception %@", exception);
1133
+ } @finally {
1134
+ pendingDeeplink = nil;
1135
+ NSLog(@"Deeplink Push : finally processPendingDeeplink pendingDeeplink set to nil");
1136
+ }
1137
+ }
1138
+
1139
+ /*----------------------------------------------------------------------------
1140
+ storePendingDeeplink
1141
+ * @param userInfo - NSDictionary
1142
+ * Store the pending deeplink info in the static variable for later processing
1143
+ -----------------------------------------------------------------------------*/
1144
+ - (void)storePendingDeeplink:(NSDictionary *)userInfo {
1145
+ @try {
1146
+ // Store the pending deeplink info in the static variable for later processing
1147
+ pendingDeeplink = userInfo;
1148
+ NSLog(@"Deeplink Push STATE: storePendingDeeplink called" );
1149
+ } @catch (NSException *exception) {
1150
+ NSLog(@"Deeplink Push STATE : storePendingDeeplink exception %@",exception);
1151
+ }
1152
+ }
1153
+
1154
+ - (void)eventClickedPayload:(NSDictionary *)userInfo {
1155
+
1156
+ NSDictionary *pushPayload = [userInfo valueForKeyPath:@"data.message"];
1157
+ NSData *payloadData = [NSJSONSerialization dataWithJSONObject:pushPayload
1158
+ options:kNilOptions
1159
+ error:nil];
1160
+ NSString *payloadString = [[NSString alloc] initWithData:payloadData encoding:NSUTF8StringEncoding];
1161
+ NSLog(@"Deeplink Push :payloadString string: %@", payloadString);
1162
+
1163
+ NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
1164
+ [self.commandDelegate evalJs:js];
1165
+ }
1166
+
1167
+
1093
1168
  @end
1094
1169
 
1095
1170
 
package/www/AppICE.js CHANGED
@@ -67,9 +67,22 @@ 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
- };
70
+ /*===========================
71
+ isDeviceReady
72
+ =============================
73
+ * isActive is to check the App state is Resumed or Paused based on that we are handling deeplink
74
+ if Resumed: isAppInitialized is set YES , process pendingPayload.
75
+ if Paused: isAppInitialized is set No. */
76
+
77
+ AppICE.prototype.isDeviceReady = function (isActive, success, error) {
78
+ if (cordova.platformId === 'ios') {
79
+ // Pass the isActive parameter for iOS
80
+ cordova.exec(success, error, "AppICEPlugin", "isDeviceReady", [isActive]);
81
+ } else {
82
+ // Do not pass the isActive parameter for Android
83
+ cordova.exec(success, error, "AppICEPlugin", "isDeviceReady", []);
84
+ }
85
+ };
73
86
 
74
87
  //==================================
75
88
  // PLAY STORE SETTING APIS