cordova-plugin-appice 2.0.10 → 2.1.2
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/example/www/js/index.js +90 -81
- package/package.json +1 -1
- package/plugin.xml +7 -4
- package/scripts/BeforeAndroidBuilt.js +63 -34
- package/src/android/AppICEFCMPush.java +26 -0
- package/src/android/AppICEMFPPush.java +24 -134
- package/src/android/AppICEPlugin.java +118 -11
- package/src/android/AppICEPushHandler.java +163 -0
- package/src/ios/AppDelegate+AppICEPlugin.m +177 -87
- package/src/ios/AppICEPlugin.h +3 -0
- package/src/ios/AppICEPlugin.m +21 -86
- package/www/AppICE.js +310 -263
|
@@ -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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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)
|
|
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
|
-
//
|
|
91
|
-
|
|
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)
|
|
197
|
+
- (void)swizzled_userNotificationCenter:(UNUserNotificationCenter *)center swizzleddidReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler{
|
|
107
198
|
|
|
108
199
|
@try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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)
|
|
236
|
+
- (void)swizzled_application:(UIApplication*)application swizzleddidFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
|
|
141
237
|
@try {
|
|
142
238
|
[[AppICEPlugin appice] handleTokenError:error];
|
|
143
|
-
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
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)
|
|
289
|
+
- (void)swizzled_userNotificationCenter:(UNUserNotificationCenter *)center
|
|
200
290
|
swizzledwillPresentNotification:(UNNotification *)notification
|
|
201
291
|
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
|
|
202
292
|
@try {
|
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,7 +158,23 @@ static NSInteger const kNotificationStackSize = 10;
|
|
|
158
158
|
-(void)onHandleNotificationUResponse:(NSDictionary *)userInfo {
|
|
159
159
|
@try {
|
|
160
160
|
NSLog(@"appice - uresponse : %@",userInfo);
|
|
161
|
-
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
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
|
+
|
|
175
|
+
NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
|
|
176
|
+
[self.commandDelegate evalJs:js];
|
|
177
|
+
}
|
|
162
178
|
|
|
163
179
|
} @catch (NSException *exception) {
|
|
164
180
|
NSLog(@"appice - uresponse : %@",exception.description);
|
|
@@ -1068,93 +1084,12 @@ static NSInteger const kNotificationStackSize = 10;
|
|
|
1068
1084
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1069
1085
|
}
|
|
1070
1086
|
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
NSDictionary *pushPayloadDict = [payloadObj valueForKey:@"pushPayload"];
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
// Check if a non-empty payload is received
|
|
1080
|
-
if (pushPayloadDict != nil && pushPayloadDict.count >0) {
|
|
1081
|
-
NSLog(@"appice - pushNotificationClicked : %@", pushPayloadDict);
|
|
1082
|
-
|
|
1083
|
-
// Call a method from the appICE SDK with the push payload dictionary
|
|
1084
|
-
[[appICE sharedInstance] handleClickOnPush:pushPayloadDict OpenDeepLink:YES];
|
|
1085
|
-
|
|
1086
|
-
// Send a success callback to the Cordova JavaScript side
|
|
1087
|
-
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1088
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1089
|
-
}
|
|
1090
|
-
} @catch (NSException *error) {
|
|
1091
|
-
// Handle any exceptions that occur during the execution
|
|
1092
|
-
NSLog(@"appice - pushNotificationClicked exception: %@", error.description);
|
|
1093
|
-
|
|
1094
|
-
// Send an error callback to the Cordova JavaScript side
|
|
1095
|
-
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
|
1096
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
- (void)getDeepLinkURL:(CDVInvokedUrlCommand *)command {
|
|
1101
|
-
@try {
|
|
1102
|
-
// Initialize user as an empty string
|
|
1103
|
-
NSString *user = @"";
|
|
1104
|
-
|
|
1105
|
-
// Attempt to extract the 'pushPayload' key from the command's arguments
|
|
1106
|
-
NSObject *payloadObj = [command argumentAtIndex:0];
|
|
1107
|
-
NSDictionary *pushPayloadDict = [payloadObj valueForKey:@"pushPayload"];
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
// Check if a non-empty payload is received
|
|
1112
|
-
if (pushPayloadDict != nil && pushPayloadDict.count >0){
|
|
1113
|
-
NSLog(@"appice - getDeepLinkURL : %@", pushPayloadDict);
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if ([pushPayloadDict valueForKeyPath:@"data.message.cdata.eurl"]) {
|
|
1117
|
-
// Extract the 'eurl' key from 'cdataDictionary'
|
|
1118
|
-
user = [pushPayloadDict valueForKeyPath:@"data.message.cdata.eurl"];
|
|
1119
|
-
}
|
|
1120
|
-
else
|
|
1121
|
-
{
|
|
1122
|
-
// If 'user' is still empty, attempt to extract 'eurl' directly from the payload
|
|
1123
|
-
if([pushPayloadDict valueForKeyPath:@"data.message.eurl"])
|
|
1124
|
-
{
|
|
1125
|
-
user = [pushPayloadDict valueForKeyPath:@"data.message.eurl"];
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
NSLog(@"Value of 'user': %@", user);
|
|
1130
|
-
|
|
1131
|
-
// Send the 'user' value as a success callback to the Cordova JavaScript side
|
|
1132
|
-
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:user];
|
|
1133
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1134
|
-
}
|
|
1135
|
-
} @catch (NSException *error) {
|
|
1136
|
-
// Handle any exceptions that occur during the execution
|
|
1137
|
-
NSLog(@"appice - getDeepLinkURL exception : %@", error.description);
|
|
1138
|
-
|
|
1139
|
-
// Send an error callback to the Cordova JavaScript side
|
|
1140
|
-
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
|
1141
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1142
|
-
}
|
|
1087
|
+
// new empty function
|
|
1088
|
+
-(void)isDeviceReady:(CDVInvokedUrlCommand *)command {
|
|
1089
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1090
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1143
1091
|
}
|
|
1144
1092
|
|
|
1145
|
-
-(BOOL)isNullOrEmptyString:(NSString*)validateString{
|
|
1146
|
-
if(![validateString isKindOfClass:[NSString class]])
|
|
1147
|
-
{
|
|
1148
|
-
return true;
|
|
1149
|
-
}
|
|
1150
|
-
if(validateString && ![validateString isEqualToString:@""])
|
|
1151
|
-
{
|
|
1152
|
-
return false;
|
|
1153
|
-
}
|
|
1154
|
-
else{
|
|
1155
|
-
return true;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
1093
|
@end
|
|
1159
1094
|
|
|
1160
1095
|
|