pushwoosh-cordova-plugin 8.3.18 → 8.3.20

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/README.md CHANGED
@@ -14,13 +14,13 @@ Cross-Platform push notifications by Pushwoosh for Cordova / PhoneGap
14
14
  Using npm (requires cordova 7.0+):
15
15
 
16
16
  ```
17
- cordova plugin add pushwoosh-cordova-plugin@8.3.18
17
+ cordova plugin add pushwoosh-cordova-plugin@8.3.20
18
18
  ```
19
19
 
20
20
  Using git:
21
21
 
22
22
  ```
23
- cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.18
23
+ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.20
24
24
  ```
25
25
 
26
26
  #### Phonegap
@@ -28,7 +28,7 @@ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.
28
28
  Using npm (requires phonegap 7.1+):
29
29
 
30
30
  ```
31
- cordova plugin add pushwoosh-cordova-plugin@8.3.18
31
+ cordova plugin add pushwoosh-cordova-plugin@8.3.20
32
32
  ```
33
33
 
34
34
  ### Guide
package/README_PGB.md CHANGED
@@ -14,7 +14,7 @@ Cross-Platform push notifications by Pushwoosh for PhoneGap
14
14
  Using npm (requires cordova 5.0+):
15
15
 
16
16
  ```
17
- cordova plugin add pushwoosh-pgb-plugin@8.3.18
17
+ cordova plugin add pushwoosh-pgb-plugin@8.3.20
18
18
  ```
19
19
 
20
20
  ### Guide
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-cordova-plugin",
3
- "version": "8.3.18",
3
+ "version": "8.3.20",
4
4
  "description": "\n This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).\n ",
5
5
  "main":"www/PushNotification.js",
6
6
  "typings":"types/index.d.ts",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="pushwoosh-cordova-plugin" version="8.3.18">
2
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="pushwoosh-cordova-plugin" version="8.3.20">
3
3
 
4
4
  <name>Pushwoosh</name>
5
5
 
@@ -77,13 +77,13 @@
77
77
  <framework src="com.github.bumptech.glide:glide:4.10.0" />
78
78
  <framework src="org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60" />
79
79
 
80
- <framework src="com.pushwoosh:pushwoosh:6.7.1"/>
81
- <framework src="com.pushwoosh:pushwoosh-amazon:6.7.1"/>
82
- <framework src="com.pushwoosh:pushwoosh-firebase:6.7.1"/>
83
- <framework src="com.pushwoosh:pushwoosh-badge:6.7.1"/>
84
- <framework src="com.pushwoosh:pushwoosh-inbox:6.7.1"/>
85
- <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.1"/>
86
- <framework src="com.pushwoosh:pushwoosh-huawei:6.7.1"/>
80
+ <framework src="com.pushwoosh:pushwoosh:6.7.2"/>
81
+ <framework src="com.pushwoosh:pushwoosh-amazon:6.7.2"/>
82
+ <framework src="com.pushwoosh:pushwoosh-firebase:6.7.2"/>
83
+ <framework src="com.pushwoosh:pushwoosh-badge:6.7.2"/>
84
+ <framework src="com.pushwoosh:pushwoosh-inbox:6.7.2"/>
85
+ <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.2"/>
86
+ <framework src="com.pushwoosh:pushwoosh-huawei:6.7.2"/>
87
87
  </platform>
88
88
 
89
89
  <!-- ios -->
@@ -15,6 +15,7 @@
15
15
  #import <PushwooshInboxUI/PushwooshInboxUI.h>
16
16
  #import <Pushwoosh/PWGDPRManager.h>
17
17
  #import <Pushwoosh/PWInAppManager.h>
18
+ #import <Pushwoosh/PushNotificationManager.h>
18
19
  #import <Pushwoosh/PWInbox.h>
19
20
  #import "PWBackward.h"
20
21
 
@@ -78,6 +79,15 @@ static PushNotification *pw_PushNotificationPlugin;
78
79
 
79
80
  @implementation PushNotification
80
81
 
82
+ API_AVAILABLE(ios(10))
83
+ __weak id<UNUserNotificationCenterDelegate> _originalNotificationCenterDelegate;
84
+ API_AVAILABLE(ios(10))
85
+ struct {
86
+ unsigned int willPresentNotification : 1;
87
+ unsigned int didReceiveNotificationResponse : 1;
88
+ unsigned int openSettingsForNotification : 1;
89
+ } _originalNotificationCenterDelegateResponds;
90
+
81
91
  #pragma clang diagnostic pop
82
92
 
83
93
  - (void)pluginInitialize {
@@ -141,7 +151,33 @@ static PushNotification *pw_PushNotificationPlugin;
141
151
  [PushNotificationManager initializeWithAppCode:appid appName:appname];
142
152
  }
143
153
 
144
- [UNUserNotificationCenter currentNotificationCenter].delegate = [PushNotificationManager pushManager].notificationCenterDelegate;
154
+ if (@available(iOS 10, *)) {
155
+ BOOL shouldReplaceDelegate = YES;
156
+ UNUserNotificationCenter *notificationCenter = [UNUserNotificationCenter currentNotificationCenter];
157
+
158
+ if (notificationCenter.delegate != nil) {
159
+ if (shouldReplaceDelegate) {
160
+ _originalNotificationCenterDelegate = notificationCenter.delegate;
161
+ _originalNotificationCenterDelegateResponds.openSettingsForNotification =
162
+ (unsigned int)[_originalNotificationCenterDelegate
163
+ respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)];
164
+ _originalNotificationCenterDelegateResponds.willPresentNotification =
165
+ (unsigned int)[_originalNotificationCenterDelegate
166
+ respondsToSelector:@selector(userNotificationCenter:
167
+ willPresentNotification:withCompletionHandler:)];
168
+ _originalNotificationCenterDelegateResponds.didReceiveNotificationResponse =
169
+ (unsigned int)[_originalNotificationCenterDelegate
170
+ respondsToSelector:@selector(userNotificationCenter:
171
+ didReceiveNotificationResponse:withCompletionHandler:)];
172
+ }
173
+ }
174
+
175
+ if (shouldReplaceDelegate) {
176
+ __strong PushNotification<UNUserNotificationCenterDelegate> *strongSelf = (PushNotification<UNUserNotificationCenterDelegate> *)self;
177
+ notificationCenter.delegate = (id<UNUserNotificationCenterDelegate>)strongSelf;
178
+ }
179
+ }
180
+
145
181
  [self.pushManager sendAppOpen];
146
182
 
147
183
  NSString * alertTypeString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"Pushwoosh_ALERT_TYPE"];
@@ -160,6 +196,98 @@ static PushNotification *pw_PushNotificationPlugin;
160
196
  [[NSUserDefaults standardUserDefaults] synchronize];
161
197
  }
162
198
 
199
+ #pragma mark - UNUserNotificationCenter Delegate Methods
200
+ #pragma mark -
201
+
202
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
203
+ willPresentNotification:(UNNotification *)notification
204
+ withCompletionHandler:
205
+ (void (^)(UNNotificationPresentationOptions options))completionHandler
206
+ API_AVAILABLE(ios(10.0)) {
207
+
208
+ if ([self isRemoteNotification:notification] && [PWMessage isPushwooshMessage:notification.request.content.userInfo]) {
209
+ completionHandler(UNNotificationPresentationOptionNone);
210
+ } else if ([PushNotificationManager pushManager].showPushnotificationAlert || [notification.request.content.userInfo objectForKey:@"pw_push"] == nil) {
211
+ completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
212
+ } else {
213
+ completionHandler(UNNotificationPresentationOptionNone);
214
+ }
215
+
216
+ if (_originalNotificationCenterDelegate != nil &&
217
+ _originalNotificationCenterDelegateResponds.willPresentNotification) {
218
+ [_originalNotificationCenterDelegate userNotificationCenter:center
219
+ willPresentNotification:notification
220
+ withCompletionHandler:completionHandler];
221
+ }
222
+ }
223
+
224
+ - (BOOL)isContentAvailablePush:(NSDictionary *)userInfo {
225
+ NSDictionary *apsDict = userInfo[@"aps"];
226
+ return apsDict[@"content-available"] != nil;
227
+ }
228
+
229
+ - (NSDictionary *)pushPayloadFromContent:(UNNotificationContent *)content {
230
+ return [[content.userInfo objectForKey:@"pw_push"] isKindOfClass:[NSDictionary class]] ? [content.userInfo objectForKey:@"pw_push"] : content.userInfo;
231
+ }
232
+
233
+ - (BOOL)isRemoteNotification:(UNNotification *)notification {
234
+ return [notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]];
235
+ }
236
+
237
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
238
+ didReceiveNotificationResponse:(UNNotificationResponse *)response
239
+ withCompletionHandler:(void (^)(void))completionHandler
240
+ API_AVAILABLE(ios(10.0)) {
241
+ dispatch_block_t handlePushAcceptanceBlock = ^{
242
+ if (![response.actionIdentifier isEqualToString:UNNotificationDismissActionIdentifier]) {
243
+ if (![response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier] && [[PushNotificationManager pushManager].delegate respondsToSelector:@selector(onActionIdentifierReceived:withNotification:)]) {
244
+ [[PushNotificationManager pushManager].delegate onActionIdentifierReceived:response.actionIdentifier withNotification:[self pushPayloadFromContent:response.notification.request.content]];
245
+ }
246
+
247
+ [[Pushwoosh sharedInstance] handlePushReceived:[self pushPayloadFromContent:response.notification.request.content]];
248
+ }
249
+ };
250
+
251
+ if ([self isRemoteNotification:response.notification] && [PWMessage isPushwooshMessage:response.notification.request.content.userInfo]) {
252
+ if (![self isContentAvailablePush:response.notification.request.content.userInfo]) {
253
+ [[Pushwoosh sharedInstance] handlePushReceived:[self pushPayloadFromContent:response.notification.request.content]];
254
+ }
255
+
256
+ handlePushAcceptanceBlock();
257
+ } else if ([response.notification.request.content.userInfo objectForKey:@"pw_push"]) {
258
+ handlePushAcceptanceBlock();
259
+ }
260
+
261
+ if (_originalNotificationCenterDelegate != nil &&
262
+ _originalNotificationCenterDelegateResponds.didReceiveNotificationResponse) {
263
+ [_originalNotificationCenterDelegate userNotificationCenter:center
264
+ didReceiveNotificationResponse:response
265
+ withCompletionHandler:completionHandler];
266
+ } else {
267
+ completionHandler();
268
+ }
269
+ }
270
+
271
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
272
+ openSettingsForNotification:(nullable UNNotification *)notification
273
+ API_AVAILABLE(ios(10.0)) {
274
+ if ([[PushNotificationManager pushManager].delegate respondsToSelector:@selector(pushManager:openSettingsForNotification:)]) {
275
+ #pragma clang diagnostic push
276
+ #pragma clang diagnostic ignored "-Wpartial-availability"
277
+ [[PushNotificationManager pushManager].delegate pushManager:[PushNotificationManager pushManager] openSettingsForNotification:notification];
278
+ #pragma clang diagnostic pop
279
+ }
280
+
281
+ if (_originalNotificationCenterDelegate != nil &&
282
+ _originalNotificationCenterDelegateResponds.openSettingsForNotification) {
283
+ #pragma clang diagnostic push
284
+ #pragma clang diagnostic ignored "-Wunguarded-availability-new"
285
+ [_originalNotificationCenterDelegate userNotificationCenter:center
286
+ openSettingsForNotification:notification];
287
+ #pragma clang diagnostic pop
288
+ }
289
+ }
290
+
163
291
  // Authorization options in addition to UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionCarPlay. Should be called before registering for pushes
164
292
  - (void)additionalAuthorizationOptions:(CDVInvokedUrlCommand *)command {
165
293
  NSDictionary *options = [command.arguments firstObject];