cordova-plugin-appice 2.0.9 → 2.1.1

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.
Files changed (34) hide show
  1. package/README.md +0 -2
  2. package/example/config.xml +59 -59
  3. package/example/package.json +38 -38
  4. package/example/res/ai_android.pem +40 -40
  5. package/example/www/css/index.css +116 -116
  6. package/example/www/index.html +62 -62
  7. package/example/www/js/index.js +111 -102
  8. package/package.json +20 -2
  9. package/plugin.xml +193 -128
  10. package/scripts/BeforeAndroidBuilt.js +165 -102
  11. package/scripts/BeforeIosBuilt.js +35 -35
  12. package/scripts/androidAfterPluginAdd.js +67 -67
  13. package/scripts/androidAfterPluginRm.js +112 -112
  14. package/scripts/iOSAfterPluginAdd.js +58 -58
  15. package/scripts/iOSAfterPluginRm.js +30 -31
  16. package/src/android/AppICEFCMPush.java +26 -0
  17. package/src/android/AppICEMFPPush.java +67 -0
  18. package/{libcordova/src/main/java/com/appice/cordova → src/android}/AppICEPlugin.java +984 -968
  19. package/src/android/AppICEPushHandler.java +163 -0
  20. package/{libcordova/src/main/java/com/appice/cordova → src/android}/CampaignCampsReceiver.java +94 -95
  21. package/{libcordova/src/main/java/com/appice/cordova → src/android}/NotificationEventService.java +64 -55
  22. package/src/build.gradle +4 -2
  23. package/src/ios/AppDelegate+AppICEPlugin.m +178 -89
  24. package/src/ios/AppICEPlugin.h +3 -0
  25. package/src/ios/AppICEPlugin.m +55 -10
  26. package/www/AppICE.js +261 -228
  27. package/libcordova/android-release-aar.gradle +0 -63
  28. package/libcordova/build.gradle +0 -50
  29. package/libcordova/cordova.jar +0 -0
  30. package/libcordova/proguard-rules.pro +0 -21
  31. package/libcordova/src/main/AndroidManifest.xml +0 -24
  32. package/libcordova/src/main/res/values/strings.xml +0 -3
  33. package/src/firebase/modified/modified.iml +0 -11
  34. package/src/firebase/original/original.iml +0 -11
@@ -17,6 +17,23 @@
17
17
  #define kApplicationInBackgroundKey @"applicationInBackground"
18
18
  #define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
19
19
 
20
+ Method originalMethodReceiveRemoteNotification;
21
+ Method swizzledMethodReceiveRemoteNotification;
22
+
23
+ Method originalMethoddidReceiveNotificationResponse;
24
+ Method swizzledMethoddidReceiveNotificationResponse;
25
+
26
+
27
+ Method originalMethodRemoteNotificationsWithDeviceToken;
28
+ Method swizzledMethodRemoteNotificationsWithDeviceToken;
29
+
30
+
31
+ Method originalMethodWillPresentNotification;
32
+ Method swizzledMethodWillPresentNotification;
33
+
34
+ Method originalMethoddidFailToRegisterRemoteNotification;
35
+ Method swizzledMethoddidFailToRegisterRemoteNotification;
36
+
20
37
  @implementation AppDelegate (AppICEPlugin)
21
38
 
22
39
  static id appdelegate;
@@ -24,33 +41,103 @@ typedef void (*OriginalImpType)(id self, SEL selector);
24
41
  static OriginalImpType originalImp;
25
42
  + (void)load {
26
43
 
27
- NSLog(@"In Appice Load method");
28
-
29
- // Swizzling method for handling received remote notifications
30
- Method originalDidReceiveRemoteNotification = class_getInstanceMethod(self, @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:));
31
- Method swizzleDidReceiveRemoteNotification = class_getInstanceMethod(self, @selector(application:swizzleddidReceiveRemoteNotification:fetchCompletionHandler:));
32
- method_exchangeImplementations(originalDidReceiveRemoteNotification, swizzleDidReceiveRemoteNotification);
33
-
34
- // Swizzling method for handling notification responses
35
- Method originalDidResponseRemoteNotification = class_getInstanceMethod(self, @selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:));
36
- Method swizzleDidResponseRemoteNotification = class_getInstanceMethod(self, @selector(userNotificationCenter:swizzleddidReceiveNotificationResponse:withCompletionHandler:));
37
- method_exchangeImplementations(originalDidResponseRemoteNotification, swizzleDidResponseRemoteNotification);
38
-
39
- // Swizzling method for handling notification will present
40
- Method originalwillPresentNotification = class_getInstanceMethod(self, @selector(userNotificationCenter:willPresentNotification:withCompletionHandler:));
41
- Method swizzlewillPresentNotification = class_getInstanceMethod(self, @selector(userNotificationCenter:swizzledwillPresentNotification:withCompletionHandler:));
42
- method_exchangeImplementations(originalwillPresentNotification, swizzlewillPresentNotification);
43
-
44
- // Swizzling method for handling device token registration for remote notifications
45
- Method originaldidRegisterForRemoteNotificationsWithDeviceToken = class_getInstanceMethod(self, @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:));
46
- Method swizzleddidRegisterForRemoteNotificationsWithDeviceToken = class_getInstanceMethod(self, @selector(application:swizzleddidRegisterForRemoteNotificationsWithDeviceToken:));
47
- method_exchangeImplementations(originaldidRegisterForRemoteNotificationsWithDeviceToken, swizzleddidRegisterForRemoteNotificationsWithDeviceToken);
48
-
49
- // Swizzling method for handling failures during remote notification registration
50
- Method originaldidFailToRegisterForRemoteNotificationsWithError = class_getInstanceMethod(self, @selector(application:didFailToRegisterForRemoteNotificationsWithError:));
51
- Method swizzleddidFailToRegisterForRemoteNotificationsWithError = class_getInstanceMethod(self, @selector(application:swizzleddidFailToRegisterForRemoteNotificationsWithError:));
52
- method_exchangeImplementations(originaldidFailToRegisterForRemoteNotificationsWithError, swizzleddidFailToRegisterForRemoteNotificationsWithError);
44
+ static dispatch_once_t onceToken;
45
+ dispatch_once(&onceToken, ^{
46
+ //for receving Notification
47
+ Class class = [self class];
48
+
49
+ SEL originalSelectorReceiveRemoteNotification = @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:);
50
+ SEL swizzledSelectorReceiveRemoteNotification = @selector(swizzled_application:swizzleddidReceiveRemoteNotification:fetchCompletionHandler:);
51
+
52
+ originalMethodReceiveRemoteNotification = class_getInstanceMethod(class, originalSelectorReceiveRemoteNotification);
53
+ swizzledMethodReceiveRemoteNotification = class_getInstanceMethod(class, swizzledSelectorReceiveRemoteNotification);
54
+
55
+ BOOL didAddMethodReceiveRemoteNotification =
56
+ class_addMethod(class, originalSelectorReceiveRemoteNotification, method_getImplementation(swizzledMethodReceiveRemoteNotification), method_getTypeEncoding(swizzledMethodReceiveRemoteNotification));
57
+
58
+ if (didAddMethodReceiveRemoteNotification) {
59
+ class_replaceMethod(class, swizzledSelectorReceiveRemoteNotification, method_getImplementation(originalMethodReceiveRemoteNotification), method_getTypeEncoding(originalMethodReceiveRemoteNotification));
60
+ } else {
61
+ method_exchangeImplementations(originalMethodReceiveRemoteNotification, swizzledMethodReceiveRemoteNotification);
62
+ }
63
+
64
+
65
+
66
+ //for notfication response
67
+
68
+ SEL originalSelectorReceiveNotificationResponse = @selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:);
69
+ SEL swizzledSelectorReceiveNotificationResponse = @selector(swizzled_userNotificationCenter:swizzleddidReceiveNotificationResponse:withCompletionHandler:);
70
+
71
+ originalMethoddidReceiveNotificationResponse = class_getInstanceMethod(class, originalSelectorReceiveNotificationResponse);
72
+ swizzledMethoddidReceiveNotificationResponse = class_getInstanceMethod(class, swizzledSelectorReceiveNotificationResponse);
73
+
74
+ BOOL didAddMethodReceiveNotificationResponse =
75
+ class_addMethod(class, originalSelectorReceiveNotificationResponse, method_getImplementation(swizzledMethoddidReceiveNotificationResponse), method_getTypeEncoding(swizzledMethoddidReceiveNotificationResponse));
76
+
77
+ if (didAddMethodReceiveNotificationResponse) {
78
+ class_replaceMethod(class, swizzledSelectorReceiveNotificationResponse, method_getImplementation(originalMethoddidReceiveNotificationResponse), method_getTypeEncoding(originalMethoddidReceiveNotificationResponse));
79
+ } else {
80
+ method_exchangeImplementations(originalMethoddidReceiveNotificationResponse, swizzledMethoddidReceiveNotificationResponse);
81
+ }
82
+
83
+
84
+ //for token
85
+
86
+ SEL originalSelectorRemoteNotificationsWithDeviceToken = @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:);
87
+ SEL swizzledSelectorRemoteNotificationsWithDeviceToken = @selector(swizzled_application:swizzleddidRegisterForRemoteNotificationsWithDeviceToken:);
88
+
89
+ originalMethodRemoteNotificationsWithDeviceToken = class_getInstanceMethod(class, originalSelectorRemoteNotificationsWithDeviceToken);
90
+ swizzledMethodRemoteNotificationsWithDeviceToken = class_getInstanceMethod(class, swizzledSelectorRemoteNotificationsWithDeviceToken);
91
+
92
+ BOOL didAddMethodRemoteNotificationsWithDeviceToken =
93
+ class_addMethod(class, originalSelectorRemoteNotificationsWithDeviceToken, method_getImplementation(swizzledMethodRemoteNotificationsWithDeviceToken), method_getTypeEncoding(swizzledMethodRemoteNotificationsWithDeviceToken));
94
+
95
+ if (didAddMethodRemoteNotificationsWithDeviceToken) {
96
+ class_replaceMethod(class, swizzledSelectorRemoteNotificationsWithDeviceToken, method_getImplementation(originalMethodRemoteNotificationsWithDeviceToken), method_getTypeEncoding(originalMethodRemoteNotificationsWithDeviceToken));
97
+ } else {
98
+ method_exchangeImplementations(originalMethodRemoteNotificationsWithDeviceToken, swizzledMethodRemoteNotificationsWithDeviceToken);
99
+ }
100
+
101
+
102
+ //will present
103
+
104
+ SEL originalSelectorWillPresentNotification = @selector(userNotificationCenter:willPresentNotification:withCompletionHandler:);
105
+ SEL swizzledSelectorWillPresentNotification = @selector(swizzled_userNotificationCenter:swizzledwillPresentNotification:withCompletionHandler:);
106
+
107
+ originalMethodWillPresentNotification = class_getInstanceMethod(class, originalSelectorWillPresentNotification);
108
+ swizzledMethodWillPresentNotification = class_getInstanceMethod(class, swizzledSelectorWillPresentNotification);
109
+
110
+ BOOL didAddMethodWillPresentNotification =
111
+ class_addMethod(class, originalSelectorWillPresentNotification, method_getImplementation(swizzledMethodWillPresentNotification), method_getTypeEncoding(swizzledMethodWillPresentNotification));
112
+
113
+ if (didAddMethodWillPresentNotification) {
114
+ class_replaceMethod(class, swizzledSelectorWillPresentNotification, method_getImplementation(originalMethodWillPresentNotification), method_getTypeEncoding(originalMethodWillPresentNotification));
115
+ } else {
116
+ method_exchangeImplementations(originalMethodWillPresentNotification, swizzledMethodWillPresentNotification);
117
+ }
118
+
119
+
120
+ //push failure
121
+
122
+ SEL originalSelectordidFailToRegisterRemoteNotification = @selector(application:didFailToRegisterForRemoteNotificationsWithError:);
123
+ SEL swizzledSelectordidFailToRegisterRemoteNotification = @selector(swizzled_application:swizzleddidFailToRegisterForRemoteNotificationsWithError:);
124
+
125
+ originalMethoddidFailToRegisterRemoteNotification = class_getInstanceMethod(class, originalSelectordidFailToRegisterRemoteNotification);
126
+ swizzledMethoddidFailToRegisterRemoteNotification = class_getInstanceMethod(class, swizzledSelectordidFailToRegisterRemoteNotification);
127
+
128
+ BOOL didAddMethoddidFailToRegisterRemoteNotification =
129
+ class_addMethod(class, originalSelectordidFailToRegisterRemoteNotification, method_getImplementation(swizzledMethoddidFailToRegisterRemoteNotification), method_getTypeEncoding(swizzledMethoddidFailToRegisterRemoteNotification));
130
+
131
+ if (didAddMethoddidFailToRegisterRemoteNotification) {
132
+ class_replaceMethod(class, swizzledSelectordidFailToRegisterRemoteNotification, method_getImplementation(originalMethoddidFailToRegisterRemoteNotification), method_getTypeEncoding(originalMethoddidFailToRegisterRemoteNotification));
133
+ } else {
134
+ method_exchangeImplementations(originalMethoddidFailToRegisterRemoteNotification, swizzledMethoddidFailToRegisterRemoteNotification);
135
+ }
136
+
137
+
138
+ });
53
139
 
140
+ NSLog(@"In Appice Load method");
54
141
 
55
142
  }
56
143
 
@@ -77,7 +164,7 @@ static OriginalImpType originalImp;
77
164
  #pragma mark - Handling received remote notifications
78
165
 
79
166
  // Swizzled method for handling received remote notifications
80
- - (void)application:(UIApplication *)application swizzleddidReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
167
+ - (void)swizzled_application:(UIApplication *)application swizzleddidReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
81
168
  NSLog(@"inside swizzledidreceive %@", userInfo);
82
169
  @try {
83
170
  // Check if the push is from Appice server.
@@ -87,8 +174,16 @@ static OriginalImpType originalImp;
87
174
  [[AppICEPlugin appice] onHandleRemoteUNotification:userInfo];
88
175
  completionHandler(UIBackgroundFetchResultNewData);
89
176
  } else {
90
- // Else, the notification is not related to Appice, so it will be handled by other third-party plugin.
91
- [self application:application swizzleddidReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
177
+ //NOTE : originalMethodReceiveRemoteNotification will be nil by default as our plugin also dont have original method. It will not be nil if any other push plugin is there
178
+ if(originalMethodReceiveRemoteNotification)
179
+ {
180
+ //caling original method over swizzling ie other plugin push method
181
+ method_exchangeImplementations(swizzledMethodReceiveRemoteNotification,originalMethodReceiveRemoteNotification);
182
+ //CALLING ORIGINAL METHOD
183
+ [self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
184
+ //reverting back our swizzling over original method of other plugin push
185
+ method_exchangeImplementations(originalMethodReceiveRemoteNotification,swizzledMethodReceiveRemoteNotification);
186
+ }
92
187
  }
93
188
  }
94
189
  @catch (NSException *exception) {
@@ -96,81 +191,87 @@ static OriginalImpType originalImp;
96
191
  }
97
192
  }
98
193
 
99
- -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
100
- NSLog(@"inside original didReceiveRemoteNotification %@",userInfo);
101
- completionHandler(UIBackgroundFetchResultNewData);
102
- }
103
194
 
104
195
  #pragma mark - Handling of remote notification response
105
196
  // Swizzled method for handling remote notification response
106
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center swizzleddidReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler{
197
+ - (void)swizzled_userNotificationCenter:(UNUserNotificationCenter *)center swizzleddidReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler{
107
198
 
108
199
  @try {
109
- NSDictionary *userInfo = response.notification.request.content.userInfo;
110
- NSLog(@"inside swizzledidresponse %@",userInfo);
111
- BOOL appIceServer = [[appICE sharedInstance] isAppICENotification:userInfo];
112
- if(appIceServer)
113
- {
114
- // If yes, Appice plugin will be notified.
115
- [[AppICEPlugin appice] onHandleNotificationUResponse:userInfo];
116
- completionHandler();
117
- }
118
- else
119
- {
120
- // Else, the notification is not related to Appice, so it will be handled by other third-party plugin.
121
- [self userNotificationCenter:center swizzleddidReceiveNotificationResponse:response withCompletionHandler:completionHandler];
122
- }
200
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
201
+ [NSThread sleepForTimeInterval:2.0f];
202
+ dispatch_async(dispatch_get_main_queue(), ^{
203
+ NSDictionary *userInfo = response.notification.request.content.userInfo;
204
+ NSLog(@"inside swizzledidresponse %@",userInfo);
205
+ BOOL appIceServer = [[appICE sharedInstance] isAppICENotification:userInfo];
206
+ if(appIceServer)
207
+ {
208
+ // If yes, Appice plugin will be notified.
209
+ [[AppICEPlugin appice] onHandleNotificationUResponse:userInfo];
210
+ completionHandler();
211
+ }
212
+ else
213
+ {
214
+ //NOTE : originalMethodReceiveRemoteNotification will be nil by default as our plugin also dont have original method. It will not be nil if any other push plugin is there
215
+
216
+ if(originalMethoddidReceiveNotificationResponse)
217
+ {
218
+ //caling original method over swizzling ie other plugin push method
219
+ method_exchangeImplementations(swizzledMethoddidReceiveNotificationResponse,originalMethoddidReceiveNotificationResponse);
220
+ //CALLING ORIGINAL METHOD
221
+ [self userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
222
+ //reverting back our swizzling over original method of other plugin push
223
+ method_exchangeImplementations(originalMethoddidReceiveNotificationResponse,swizzledMethoddidReceiveNotificationResponse);
224
+ }
225
+ }
226
+ });
227
+ });
123
228
 
124
229
  }
125
230
  @catch (NSException *exception) {
126
231
  NSLog(@"exception from did response notfication cordova = %@",exception.reason);
127
232
  }
128
233
  }
129
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler{
130
-
131
- @try {
132
- NSLog(@"In original userNotificationCenter");
133
- }
134
- @catch (NSException *exception) {
135
-
136
- }
137
- }
138
234
  #pragma mark - Handling of remote notification registration failures
139
235
  // Swizzled method for handling remote notification registration failures
140
- - (void)application:(UIApplication*)application swizzleddidFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
236
+ - (void)swizzled_application:(UIApplication*)application swizzleddidFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
141
237
  @try {
142
238
  [[AppICEPlugin appice] handleTokenError:error];
143
- [self application:application swizzleddidFailToRegisterForRemoteNotificationsWithError:error];
239
+
240
+ if(originalMethoddidFailToRegisterRemoteNotification)
241
+ {
242
+ //caling original method over swizzling ie other plugin push method
243
+ method_exchangeImplementations(swizzledMethodReceiveRemoteNotification,originalMethodReceiveRemoteNotification);
244
+ //CALLING ORIGINAL METHOD
245
+ [self application:application didFailToRegisterForRemoteNotificationsWithError:error];
246
+ //reverting back our swizzling over original method of other plugin push
247
+ method_exchangeImplementations(originalMethoddidFailToRegisterRemoteNotification,swizzledMethoddidFailToRegisterRemoteNotification);
248
+ }
249
+
144
250
  } @catch (NSException *exception) {
145
251
  NSLog(@"exception from swizzleddidFailToRegisterForRemoteNotificationsWithError cordova = %@",exception.reason);
146
252
  }
147
253
  }
148
- - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
149
- @try {
150
- NSLog(@"in original didFailToRegisterForRemoteNotificationsWithError");
151
- } @catch (NSException *exception) {
152
- }
153
- }
254
+
154
255
  #pragma mark - Handle Device Token
155
256
  // Swizzled method for handling Device Token
156
- - (void)application:(UIApplication*)application swizzleddidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
257
+ - (void)swizzled_application:(UIApplication*)application swizzleddidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
157
258
  @try {
158
259
  NSLog(@"apns token appIce %@",deviceToken);
159
260
  [[AppICEPlugin appice] handleToken:deviceToken];
160
- [self application:application swizzleddidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
261
+ if(originalMethodRemoteNotificationsWithDeviceToken){
262
+ //caling original method over swizzling ie other plugin push method
263
+ method_exchangeImplementations(swizzledMethodRemoteNotificationsWithDeviceToken,originalMethodRemoteNotificationsWithDeviceToken);
264
+ //CALLING ORIGINAL METHOD
265
+ [self application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
266
+ //reverting back our swizzling over original method of other plugin push
267
+ method_exchangeImplementations(originalMethodRemoteNotificationsWithDeviceToken,swizzledMethodRemoteNotificationsWithDeviceToken);
268
+ }
269
+
161
270
 
162
271
  } @catch(NSException *e){
163
272
  NSLog(@"exception from swizzleddidRegisterForRemoteNotificationsWithDeviceToken cordova = %@",e.reason);
164
273
  }
165
274
  }
166
- - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
167
- {
168
- @try {
169
- NSLog(@"inside didRegisterForRemoteNotificationsWithDeviceToken %@",deviceToken);
170
-
171
- } @catch (NSException *exception) {
172
- }
173
- }
174
275
  #pragma mark - Handle Local Notification
175
276
 
176
277
  - (void) application:(UIApplication*)application didReceiveLocalNotification:(UILocalNotification*)notification {
@@ -184,19 +285,8 @@ static OriginalImpType originalImp;
184
285
  #pragma mark - Handling of remote notification willPresentNotification
185
286
 
186
287
  #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
187
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center
188
- willPresentNotification:(UNNotification *)notification
189
- withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
190
- @try {
191
- NSLog(@"inside original willPresentNotification");
192
- } @catch (NSException *exception) {
193
-
194
- } @finally {
195
-
196
- }
197
- }
198
288
 
199
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center
289
+ - (void)swizzled_userNotificationCenter:(UNUserNotificationCenter *)center
200
290
  swizzledwillPresentNotification:(UNNotification *)notification
201
291
  withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
202
292
  @try {
@@ -270,10 +360,9 @@ swizzledwillPresentNotification:(UNNotification *)notification
270
360
 
271
361
  - (void)openURL:(NSURL*)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion {
272
362
  @try {
273
- [[AppICEPlugin appice] onHandleOpenURLNotification:url];
363
+
274
364
  } @catch (NSException *exception) {
275
365
  }
276
366
  }
277
367
 
278
368
  @end
279
-
@@ -85,6 +85,9 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
85
85
 
86
86
  -(void)onHandleRemoteUNotification:(NSDictionary *)userInfo;
87
87
  -(void)onHandleNotificationUResponse:(NSDictionary *)userInfo;
88
+ -(void)registerLifeCycle:(CDVInvokedUrlCommand *)command;
89
+ -(void)pushNotificationClicked:(CDVInvokedUrlCommand *)command;
90
+ -(void)getDeepLinkURL:(CDVInvokedUrlCommand *)command;
88
91
 
89
92
  @end
90
93
 
@@ -1,4 +1,3 @@
1
-
2
1
  #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
3
2
  @import UserNotifications;
4
3
  #endif
@@ -31,8 +30,10 @@ NSTimeInterval requestTime;
31
30
  static AppICEPlugin *appice;
32
31
 
33
32
  static NSInteger const kNotificationStackSize = 10;
34
- @synthesize notificationCallbackId;
35
- @synthesize notificationStack;
33
+ @synthesize notificationCallbackId; // Manages the callback ID for notifications.
34
+ @synthesize notificationStack; // Stack to hold pending notifications.
35
+
36
+
36
37
 
37
38
  +(void)load {
38
39
 
@@ -157,14 +158,41 @@ static NSInteger const kNotificationStackSize = 10;
157
158
  -(void)onHandleNotificationUResponse:(NSDictionary *)userInfo {
158
159
  @try {
159
160
  NSLog(@"appice - uresponse : %@",userInfo);
160
-
161
- BOOL appIceServer = [[appICE sharedInstance] isAppICENotification:userInfo];
162
- if(appIceServer)
163
- {
164
- [[appICE sharedInstance] handleClickOnPush:userInfo OpenDeepLink:YES];
165
- [self sendCallback:userInfo];
161
+ NSString *deepLinkurl = @"";
162
+ [[appICE sharedInstance]handleClickOnPush:userInfo OpenDeepLink:YES];
163
+
164
+ if (userInfo != nil && userInfo.count >0){
165
+ NSLog(@"appice - getDeepLinkURL : %@", userInfo);
166
+
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
+
181
+ NSLog(@"Value of 'user': %@", deepLinkurl);
182
+
183
+ NSString *js = [NSString stringWithFormat:@"onDeepLink({'deeplink':'%@'});",deepLinkurl];
184
+ [self.commandDelegate evalJs:js];
167
185
  }
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
+
168
196
  } @catch (NSException *exception) {
169
197
  NSLog(@"appice - uresponse : %@",exception.description);
170
198
  } @finally {
@@ -212,7 +240,9 @@ static NSInteger const kNotificationStackSize = 10;
212
240
  if (userInfo != NULL&& [userInfo objectForKey:@"data"] != NULL) {
213
241
  NSDictionary *data = [userInfo objectForKey:@"data"];
214
242
  NSDictionary *message = [data objectForKey:@"message"];
243
+ NSDictionary *cdata = [message objectForKey:@"cdata"];
215
244
  [self sendNotification:userInfo];
245
+
216
246
  if (message != NULL && [message objectForKey:@"et"] != NULL) {
217
247
  NSString *et = [message objectForKey:@"et"];
218
248
  if (et != NULL
@@ -233,7 +263,7 @@ static NSInteger const kNotificationStackSize = 10;
233
263
  } @catch(NSException *e) {}
234
264
 
235
265
  @try {
236
- NSDictionary *cdata = [message objectForKey:@"cdata"];
266
+
237
267
  NSString *template = [cdata objectForKey:@"template"];
238
268
  if (template != NULL
239
269
  && [template isKindOfClass:[NSString class]]
@@ -413,6 +443,7 @@ static NSInteger const kNotificationStackSize = 10;
413
443
  return params;
414
444
  }
415
445
 
446
+
416
447
  -(void)onHandleOpenURLNotification:(NSURL *)url {
417
448
 
418
449
  }
@@ -1025,7 +1056,16 @@ static NSInteger const kNotificationStackSize = 10;
1025
1056
 
1026
1057
  }
1027
1058
  }
1059
+ /**
1060
+ Sends a notification to the registered callback if available; otherwise, stacks the notification for future processing.
1028
1061
 
1062
+ @param userInfo The dictionary containing notification information.
1063
+
1064
+ This method attempts to send a notification to the registered callback if it exists.
1065
+ If the callback is available, it creates a plugin result with the provided notification data, sets the callback to persist, and sends the result to the command delegate using the notification callback ID.
1066
+ If no callback is registered, it stacks the notification in a queue (notificationStack) for later processing.
1067
+ It limits the stack size to a predefined constant (kNotificationStackSize) to manage memory usage.
1068
+ */
1029
1069
  - (void)sendNotification:(NSDictionary *)userInfo {
1030
1070
  @try {
1031
1071
  NSLog(@"Appice send-notifcallback a1 %@",notificationCallbackId);
@@ -1056,7 +1096,12 @@ static NSInteger const kNotificationStackSize = 10;
1056
1096
 
1057
1097
  }
1058
1098
  }
1099
+ -(void)registerLifeCycle:(CDVInvokedUrlCommand *)command {
1100
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1101
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
1102
+ }
1059
1103
 
1060
1104
  @end
1061
1105
 
1062
1106
 
1107
+