pushwoosh-react-native-plugin 6.1.24 → 6.1.26

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.
@@ -58,6 +58,8 @@ body:
58
58
  label: Your Pushwoosh React Native Plugin version
59
59
  description: Your React Native Plugin version which was integrated to the app. You may find it on the [releases page](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases)
60
60
  options:
61
+ - 6.1.26
62
+ - 6.1.25
61
63
  - 6.1.23
62
64
  - 6.1.22
63
65
  - 6.1.21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-react-native-plugin",
3
- "version": "6.1.24",
3
+ "version": "6.1.26",
4
4
  "description": "This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = "pushwoosh-react-native-plugin"
3
- s.version = "6.1.24"
3
+ s.version = "6.1.26"
4
4
  s.summary = "React Native Pushwoosh Push Notifications module"
5
5
  s.requires_arc = true
6
6
  s.author = 'Pushwoosh'
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  ext {
40
- pushwoosh = "6.6.17"
40
+ pushwoosh = "6.7.1"
41
41
  }
42
42
 
43
43
  dependencies {
@@ -18,7 +18,7 @@
18
18
 
19
19
  #endif
20
20
 
21
- #define PUSHWOOSH_VERSION @"6.5.4"
21
+ #define PUSHWOOSH_VERSION @"6.5.5"
22
22
 
23
23
 
24
24
  @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy;
@@ -13,6 +13,7 @@
13
13
  #import <React/RCTConvert.h>
14
14
 
15
15
  #import <UserNotifications/UserNotifications.h>
16
+ #import <Pushwoosh/PushNotificationManager.h>
16
17
 
17
18
  static id objectOrNull(id object) {
18
19
  if (object) {
@@ -33,6 +34,15 @@ static NSString * const kPushReceivedJSEvent = @"pushReceived";
33
34
 
34
35
  @implementation PushwooshPlugin
35
36
 
37
+ API_AVAILABLE(ios(10))
38
+ __weak id<UNUserNotificationCenterDelegate> _originalNotificationCenterDelegate;
39
+ API_AVAILABLE(ios(10))
40
+ struct {
41
+ unsigned int willPresentNotification : 1;
42
+ unsigned int didReceiveNotificationResponse : 1;
43
+ unsigned int openSettingsForNotification : 1;
44
+ } _originalNotificationCenterDelegateResponds;
45
+
36
46
  #pragma mark - Pushwoosh RCTBridgeModule
37
47
 
38
48
  RCT_EXPORT_MODULE(Pushwoosh);
@@ -64,7 +74,28 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
64
74
 
65
75
  // We set Pushwoosh UNUserNotificationCenter delegate unless CUSTOM is specified in the config
66
76
  if(![notificationHandling isEqualToString:@"CUSTOM"]) {
67
- [UNUserNotificationCenter currentNotificationCenter].delegate = [PushNotificationManager pushManager].notificationCenterDelegate;
77
+ if (@available(iOS 10, *)) {
78
+
79
+ UNUserNotificationCenter *notificationCenter = [UNUserNotificationCenter currentNotificationCenter];
80
+
81
+ if (notificationCenter.delegate != nil) {
82
+ _originalNotificationCenterDelegate = notificationCenter.delegate;
83
+ _originalNotificationCenterDelegateResponds.openSettingsForNotification =
84
+ (unsigned int)[_originalNotificationCenterDelegate
85
+ respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)];
86
+ _originalNotificationCenterDelegateResponds.willPresentNotification =
87
+ (unsigned int)[_originalNotificationCenterDelegate
88
+ respondsToSelector:@selector(userNotificationCenter:
89
+ willPresentNotification:withCompletionHandler:)];
90
+ _originalNotificationCenterDelegateResponds.didReceiveNotificationResponse =
91
+ (unsigned int)[_originalNotificationCenterDelegate
92
+ respondsToSelector:@selector(userNotificationCenter:
93
+ didReceiveNotificationResponse:withCompletionHandler:)];
94
+ }
95
+
96
+ __strong PushwooshPlugin<UNUserNotificationCenterDelegate> *strongSelf = (PushwooshPlugin<UNUserNotificationCenterDelegate> *)self;
97
+ notificationCenter.delegate = (id<UNUserNotificationCenterDelegate>)strongSelf;
98
+ }
68
99
  }
69
100
 
70
101
  if (success) {
@@ -300,6 +331,119 @@ RCT_EXPORT_METHOD(performAction:(NSString*)code) {
300
331
  [PWInbox performActionForMessageWithCode:code];
301
332
  }
302
333
 
334
+ #pragma mark - UNUserNotificationCenter Delegate Methods
335
+ #pragma mark -
336
+
337
+ #pragma mark - UNUserNotificationCenter Delegate Methods
338
+ #pragma mark -
339
+
340
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
341
+ willPresentNotification:(UNNotification *)notification
342
+ withCompletionHandler:
343
+ (void (^)(UNNotificationPresentationOptions options))completionHandler
344
+ API_AVAILABLE(ios(10.0)) {
345
+
346
+ if ([self isRemoteNotification:notification] && [PWMessage isPushwooshMessage:notification.request.content.userInfo]) {
347
+ UNMutableNotificationContent *content = notification.request.content.mutableCopy;
348
+
349
+ NSMutableDictionary *userInfo = content.userInfo.mutableCopy;
350
+ userInfo[@"pw_push"] = @(YES);
351
+
352
+ content.userInfo = userInfo;
353
+
354
+ //newsstand push
355
+ if (![self isContentAvailablePush:userInfo]) {
356
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushReceivedEvent withArgs:@[ objectOrNull(userInfo) ]];
357
+
358
+ [self sendJSEvent:kPushReceivedJSEvent withArgs:userInfo];
359
+ }
360
+
361
+ completionHandler(UNNotificationPresentationOptionNone);
362
+ } else if ([PushNotificationManager pushManager].showPushnotificationAlert || [notification.request.content.userInfo objectForKey:@"pw_push"] == nil) {
363
+ completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
364
+ } else {
365
+ completionHandler(UNNotificationPresentationOptionNone);
366
+ }
367
+
368
+ if (_originalNotificationCenterDelegate != nil &&
369
+ _originalNotificationCenterDelegateResponds.willPresentNotification) {
370
+ [_originalNotificationCenterDelegate userNotificationCenter:center
371
+ willPresentNotification:notification
372
+ withCompletionHandler:completionHandler];
373
+ }
374
+ }
375
+
376
+ - (BOOL)isContentAvailablePush:(NSDictionary *)userInfo {
377
+ NSDictionary *apsDict = userInfo[@"aps"];
378
+ return apsDict[@"content-available"] != nil;
379
+ }
380
+
381
+ - (NSDictionary *)pushPayloadFromContent:(UNNotificationContent *)content {
382
+ return [[content.userInfo objectForKey:@"pw_push"] isKindOfClass:[NSDictionary class]] ? [content.userInfo objectForKey:@"pw_push"] : content.userInfo;
383
+ }
384
+
385
+ - (BOOL)isRemoteNotification:(UNNotification *)notification {
386
+ return [notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]];
387
+ }
388
+
389
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
390
+ didReceiveNotificationResponse:(UNNotificationResponse *)response
391
+ withCompletionHandler:(void (^)(void))completionHandler
392
+ API_AVAILABLE(ios(10.0)) {
393
+ dispatch_block_t handlePushAcceptanceBlock = ^{
394
+ if (![response.actionIdentifier isEqualToString:UNNotificationDismissActionIdentifier]) {
395
+ if (![response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier] && [[PushNotificationManager pushManager].delegate respondsToSelector:@selector(onActionIdentifierReceived:withNotification:)]) {
396
+ [[PushNotificationManager pushManager].delegate onActionIdentifierReceived:response.actionIdentifier withNotification:[self pushPayloadFromContent:response.notification.request.content]];
397
+ }
398
+
399
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(response.notification.request.content.userInfo) ]];
400
+
401
+ [self sendJSEvent:kPushOpenJSEvent withArgs:response.notification.request.content.userInfo];
402
+ }
403
+ };
404
+
405
+ if ([self isRemoteNotification:response.notification] && [PWMessage isPushwooshMessage:response.notification.request.content.userInfo]) {
406
+ if (![self isContentAvailablePush:response.notification.request.content.userInfo]) {
407
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(response.notification.request.content.userInfo) ]];
408
+
409
+ [self sendJSEvent:kPushOpenJSEvent withArgs:response.notification.request.content.userInfo];
410
+ }
411
+
412
+ handlePushAcceptanceBlock();
413
+ } else if ([response.notification.request.content.userInfo objectForKey:@"pw_push"]) {
414
+ handlePushAcceptanceBlock();
415
+ }
416
+
417
+ if (_originalNotificationCenterDelegate != nil &&
418
+ _originalNotificationCenterDelegateResponds.didReceiveNotificationResponse) {
419
+ [_originalNotificationCenterDelegate userNotificationCenter:center
420
+ didReceiveNotificationResponse:response
421
+ withCompletionHandler:completionHandler];
422
+ } else {
423
+ completionHandler();
424
+ }
425
+ }
426
+
427
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
428
+ openSettingsForNotification:(nullable UNNotification *)notification
429
+ API_AVAILABLE(ios(10.0)) {
430
+ if ([[PushNotificationManager pushManager].delegate respondsToSelector:@selector(pushManager:openSettingsForNotification:)]) {
431
+ #pragma clang diagnostic push
432
+ #pragma clang diagnostic ignored "-Wpartial-availability"
433
+ [[PushNotificationManager pushManager].delegate pushManager:[PushNotificationManager pushManager] openSettingsForNotification:notification];
434
+ #pragma clang diagnostic pop
435
+ }
436
+
437
+ if (_originalNotificationCenterDelegate != nil &&
438
+ _originalNotificationCenterDelegateResponds.openSettingsForNotification) {
439
+ #pragma clang diagnostic push
440
+ #pragma clang diagnostic ignored "-Wunguarded-availability-new"
441
+ [_originalNotificationCenterDelegate userNotificationCenter:center
442
+ openSettingsForNotification:notification];
443
+ #pragma clang diagnostic pop
444
+ }
445
+ }
446
+
303
447
  - (NSDictionary*)inboxMessageToDictionary:(NSObject<PWInboxMessageProtocol>*) message {
304
448
  NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
305
449
  [dictionary setValue:@(message.type) forKey:@"type"];
@@ -581,18 +725,6 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
581
725
  [[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationErrorEvent withArgs:@[ objectOrNull([error localizedDescription]) ]];
582
726
  }
583
727
 
584
- - (void)onPushReceived:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
585
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushReceivedEvent withArgs:@[ objectOrNull(pushNotification) ]];
586
-
587
- [self sendJSEvent:kPushReceivedJSEvent withArgs:pushNotification];
588
- }
589
-
590
- - (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
591
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushNotification) ]];
592
-
593
- [self sendJSEvent:kPushOpenJSEvent withArgs:pushNotification];
594
- }
595
-
596
728
  #pragma mark - RCTEventEmitter
597
729
 
598
730
  - (void)sendJSEvent:(NSString*)event withArgs:(NSDictionary*)args {
Binary file