pushwoosh-cordova-plugin 8.3.36 → 8.3.38

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 Cordova plugin version
59
59
  description: Your version of the Cordova plugin integrated into the application. You may find it on the [releases page](https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/releases)
60
60
  options:
61
+ - 8.3.38
62
+ - 8.3.37
61
63
  - 8.3.36
62
64
  - 8.3.35
63
65
  - 8.3.34
package/README.md CHANGED
@@ -14,13 +14,13 @@ Cross-Platform push notifications by Pushwoosh for Cordova / PhoneGap
14
14
  Using npm:
15
15
 
16
16
  ```
17
- cordova plugin add pushwoosh-cordova-plugin@8.3.36
17
+ cordova plugin add pushwoosh-cordova-plugin@8.3.38
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.36
23
+ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.38
24
24
  ```
25
25
 
26
26
  ### Guide
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-cordova-plugin",
3
- "version": "8.3.36",
3
+ "version": "8.3.38",
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.36">
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.38">
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.16"/>
81
- <framework src="com.pushwoosh:pushwoosh-amazon:6.7.16"/>
82
- <framework src="com.pushwoosh:pushwoosh-firebase:6.7.16"/>
83
- <framework src="com.pushwoosh:pushwoosh-badge:6.7.16"/>
84
- <framework src="com.pushwoosh:pushwoosh-inbox:6.7.16"/>
85
- <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.16"/>
86
- <framework src="com.pushwoosh:pushwoosh-huawei:6.7.16"/>
80
+ <framework src="com.pushwoosh:pushwoosh:6.7.24"/>
81
+ <framework src="com.pushwoosh:pushwoosh-amazon:6.7.24"/>
82
+ <framework src="com.pushwoosh:pushwoosh-firebase:6.7.24"/>
83
+ <framework src="com.pushwoosh:pushwoosh-badge:6.7.24"/>
84
+ <framework src="com.pushwoosh:pushwoosh-inbox:6.7.24"/>
85
+ <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.24"/>
86
+ <framework src="com.pushwoosh:pushwoosh-huawei:6.7.24"/>
87
87
  </platform>
88
88
 
89
89
  <!-- ios -->
@@ -125,7 +125,7 @@
125
125
  <source url="https://github.com/CocoaPods/Specs.git"/>
126
126
  </config>
127
127
  <pods use-frameworks="true">
128
- <pod name="PushwooshXCFramework" spec="6.7.13" />
128
+ <pod name="PushwooshXCFramework" spec="6.8.5" />
129
129
  <pod name="PushwooshInboxUIXCFramework" spec="6.1.2" />
130
130
  </pods>
131
131
  </podspec>
@@ -1070,6 +1070,17 @@ public class PushNotifications extends CordovaPlugin {
1070
1070
  return true;
1071
1071
  }
1072
1072
 
1073
+ @CordovaMethod
1074
+ private boolean setApiToken(JSONArray data, final CallbackContext callbackContextn) {
1075
+ try {
1076
+ String token = data.getString(0);
1077
+ Pushwoosh.getInstance().setApiToken(token);
1078
+ } catch (JSONException e) {
1079
+ PWLog.error(TAG, "No parameters passed (missing parameters)", e);
1080
+ }
1081
+ return true;
1082
+ }
1083
+
1073
1084
  private static JSONObject inboxMessageToJson(InboxMessage message) {
1074
1085
  JSONObject object = new JSONObject();
1075
1086
  try {
@@ -62,17 +62,17 @@
62
62
  @end
63
63
 
64
64
  void pushwoosh_swizzle(Class class, SEL fromChange, SEL toChange, IMP impl, const char * signature) {
65
- Method method = nil;
66
- method = class_getInstanceMethod(class, fromChange);
67
-
68
- if (method) {
69
- //method exists add a new method and swap with original
70
- class_addMethod(class, toChange, impl, signature);
71
- method_exchangeImplementations(class_getInstanceMethod(class, fromChange), class_getInstanceMethod(class, toChange));
72
- } else {
73
- //just add as orignal method
74
- class_addMethod(class, fromChange, impl, signature);
75
- }
65
+ Method method = nil;
66
+ method = class_getInstanceMethod(class, fromChange);
67
+
68
+ if (method) {
69
+ //method exists add a new method and swap with original
70
+ class_addMethod(class, toChange, impl, signature);
71
+ method_exchangeImplementations(class_getInstanceMethod(class, fromChange), class_getInstanceMethod(class, toChange));
72
+ } else {
73
+ //just add as orignal method
74
+ class_addMethod(class, fromChange, impl, signature);
75
+ }
76
76
  }
77
77
 
78
78
  static PushNotification *pw_PushNotificationPlugin;
@@ -133,44 +133,49 @@ API_AVAILABLE(ios(10))
133
133
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
134
134
  }
135
135
 
136
+ - (void)setApiToken:(CDVInvokedUrlCommand *)command {
137
+ NSString *token = command.arguments[0];
138
+ [[PWSettings settings] setApiToken:token];
139
+ }
140
+
136
141
  - (void)onDeviceReady:(CDVInvokedUrlCommand *)command {
137
- NSDictionary *options = [command.arguments firstObject];
138
-
139
- NSString *appid = options[@"pw_appid"];
140
- if (!appid) {
141
- appid = options[@"appid"];
142
- }
143
-
144
- NSString *appname = options[@"appname"];
145
-
146
- if (!appid) {
147
- //no Pushwoosh App Id provided in JS call, let's try Info.plist (SDK default)
148
- if (self.pushManager == nil) {
149
- PWLogError(@"PushNotification.registerDevice: Missing Pushwoosh App ID");
150
- return;
151
- }
152
- }
153
- else {
154
- [PushNotificationManager initializeWithAppCode:appid appName:appname];
155
- }
142
+ NSDictionary *options = [command.arguments firstObject];
143
+
144
+ NSString *appid = options[@"pw_appid"];
145
+ if (!appid) {
146
+ appid = options[@"appid"];
147
+ }
148
+
149
+ NSString *appname = options[@"appname"];
150
+
151
+ if (!appid) {
152
+ //no Pushwoosh App Id provided in JS call, let's try Info.plist (SDK default)
153
+ if (self.pushManager == nil) {
154
+ PWLogError(@"PushNotification.registerDevice: Missing Pushwoosh App ID");
155
+ return;
156
+ }
157
+ }
158
+ else {
159
+ [PushNotificationManager initializeWithAppCode:appid appName:appname];
160
+ }
156
161
 
157
162
  [UNUserNotificationCenter currentNotificationCenter].delegate = [PushNotificationManager pushManager].notificationCenterDelegate;
158
- [self.pushManager sendAppOpen];
163
+ [self.pushManager sendAppOpen];
159
164
 
160
- NSString * alertTypeString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"Pushwoosh_ALERT_TYPE"];
161
- if([alertTypeString isKindOfClass:[NSString class]] && [alertTypeString isEqualToString:@"NONE"]) {
162
- self.pushManager.showPushnotificationAlert = NO;
163
- }
165
+ NSString * alertTypeString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"Pushwoosh_ALERT_TYPE"];
166
+ if([alertTypeString isKindOfClass:[NSString class]] && [alertTypeString isEqualToString:@"NONE"]) {
167
+ self.pushManager.showPushnotificationAlert = NO;
168
+ }
164
169
 
165
170
  _deviceReady = YES;
166
-
167
- if (self.pushwoosh.launchNotification) {
171
+
172
+ if (self.pushwoosh.launchNotification) {
168
173
  NSDictionary *notification = [self createNotificationDataForPush:self.pushwoosh.launchNotification onStart:YES];
169
174
  [self dispatchPushReceive:notification];
170
175
  [self dispatchPushAccept:notification];
171
- }
176
+ }
172
177
 
173
- [[NSUserDefaults standardUserDefaults] synchronize];
178
+ [[NSUserDefaults standardUserDefaults] synchronize];
174
179
  }
175
180
 
176
181
  #pragma mark - UNUserNotificationCenter Delegate Methods
@@ -302,16 +307,16 @@ API_AVAILABLE(ios(10.0)) {
302
307
  }
303
308
 
304
309
  - (void)registerDevice:(CDVInvokedUrlCommand *)command {
305
- [PushNotification swizzleNotificationSettingsHandler];
306
-
307
- self.callbackIds[@"registerDevice"] = command.callbackId;
310
+ [PushNotification swizzleNotificationSettingsHandler];
311
+
312
+ self.callbackIds[@"registerDevice"] = command.callbackId;
308
313
 
309
- //Cordova BUG: https://issues.apache.org/jira/browse/CB-8063
310
- // CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT messageAsDictionary:nil];
311
- // [pluginResult setKeepCallbackAsBool:YES];
312
- // [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
314
+ //Cordova BUG: https://issues.apache.org/jira/browse/CB-8063
315
+ // CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT messageAsDictionary:nil];
316
+ // [pluginResult setKeepCallbackAsBool:YES];
317
+ // [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
313
318
 
314
- [[PushNotificationManager pushManager] registerForPushNotifications];
319
+ [[PushNotificationManager pushManager] registerForPushNotifications];
315
320
  }
316
321
 
317
322
  - (void)unregisterDevice:(CDVInvokedUrlCommand *)command {
@@ -343,42 +348,42 @@ API_AVAILABLE(ios(10.0)) {
343
348
  }
344
349
 
345
350
  - (void)startBeaconPushes:(CDVInvokedUrlCommand *)command {
346
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
347
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
351
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
352
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
348
353
  }
349
354
 
350
355
  - (void)stopBeaconPushes:(CDVInvokedUrlCommand *)command {
351
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
352
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
356
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
357
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
353
358
  }
354
359
 
355
360
  - (void)setTags:(CDVInvokedUrlCommand *)command {
356
- [[PushNotificationManager pushManager] setTags:command.arguments[0]];
361
+ [[PushNotificationManager pushManager] setTags:command.arguments[0]];
357
362
 
358
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:nil];
359
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
363
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:nil];
364
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
360
365
  }
361
366
 
362
367
  - (void)getTags:(CDVInvokedUrlCommand *)command {
363
- // The first argument in the arguments parameter is the callbackID.
364
- self.callbackIds[@"getTags"] = command.callbackId;
368
+ // The first argument in the arguments parameter is the callbackID.
369
+ self.callbackIds[@"getTags"] = command.callbackId;
365
370
 
366
- //Cordova BUG: https://issues.apache.org/jira/browse/CB-8063
367
- // CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT messageAsDictionary:nil];
368
- // [pluginResult setKeepCallbackAsBool:YES];
369
- // [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
371
+ //Cordova BUG: https://issues.apache.org/jira/browse/CB-8063
372
+ // CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT messageAsDictionary:nil];
373
+ // [pluginResult setKeepCallbackAsBool:YES];
374
+ // [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
370
375
 
371
- [[PushNotificationManager pushManager] loadTags:^(NSDictionary *tags) {
372
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:tags];
373
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"getTags"]];
374
- } error:^(NSError *error) {
375
- NSMutableDictionary *results = [NSMutableDictionary dictionary];
376
- results[@"error"] = [NSString stringWithFormat:@"%@", error];
376
+ [[PushNotificationManager pushManager] loadTags:^(NSDictionary *tags) {
377
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:tags];
378
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"getTags"]];
379
+ } error:^(NSError *error) {
380
+ NSMutableDictionary *results = [NSMutableDictionary dictionary];
381
+ results[@"error"] = [NSString stringWithFormat:@"%@", error];
377
382
 
378
- CDVPluginResult *pluginResult =
379
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
380
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"getTags"]];
381
- }];
383
+ CDVPluginResult *pluginResult =
384
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
385
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"getTags"]];
386
+ }];
382
387
  }
383
388
 
384
389
  - (void)loadMessages:(CDVInvokedUrlCommand *)command {
@@ -499,21 +504,21 @@ API_AVAILABLE(ios(10.0)) {
499
504
  }
500
505
 
501
506
  - (void)onDidRegisterForRemoteNotificationsWithDeviceToken:(NSString *)token {
502
- if (self.callbackIds[@"registerDevice"]) {
503
- NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
504
- results[@"pushToken"] = token;
505
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
506
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"registerDevice"]];
507
- }
507
+ if (self.callbackIds[@"registerDevice"]) {
508
+ NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
509
+ results[@"pushToken"] = token;
510
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
511
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"registerDevice"]];
512
+ }
508
513
  }
509
514
 
510
515
  - (void)onDidFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
511
- if (self.callbackIds[@"registerDevice"]) {
512
- NSMutableDictionary *results = [NSMutableDictionary dictionary];
513
- results[@"error"] = [NSString stringWithFormat:@"%@", error];
514
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
515
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"registerDevice"]];
516
- }
516
+ if (self.callbackIds[@"registerDevice"]) {
517
+ NSMutableDictionary *results = [NSMutableDictionary dictionary];
518
+ results[@"error"] = [NSString stringWithFormat:@"%@", error];
519
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
520
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"registerDevice"]];
521
+ }
517
522
  }
518
523
 
519
524
  - (NSDictionary *)createNotificationDataForPush:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
@@ -574,18 +579,18 @@ API_AVAILABLE(ios(10.0)) {
574
579
  }
575
580
 
576
581
  - (void)getRemoteNotificationStatus:(CDVInvokedUrlCommand *)command {
577
- NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
582
+ NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
578
583
 
579
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
580
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
584
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
585
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
581
586
  }
582
587
 
583
588
  - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
584
- int badge = [command.arguments[0][@"badge"] intValue];
585
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
589
+ int badge = [command.arguments[0][@"badge"] intValue];
590
+ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
586
591
 
587
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
588
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
592
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
593
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
589
594
  }
590
595
 
591
596
  - (void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
@@ -596,32 +601,32 @@ API_AVAILABLE(ios(10.0)) {
596
601
  }
597
602
 
598
603
  - (void)addToApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
599
- int badge = [command.arguments[0][@"badge"] intValue];
600
- [UIApplication sharedApplication].applicationIconBadgeNumber += badge;
604
+ int badge = [command.arguments[0][@"badge"] intValue];
605
+ [UIApplication sharedApplication].applicationIconBadgeNumber += badge;
601
606
 
602
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
603
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
607
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
608
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
604
609
  }
605
610
 
606
611
  - (void)cancelAllLocalNotifications:(CDVInvokedUrlCommand *)command {
607
- [UIApplication sharedApplication].scheduledLocalNotifications = @[];
612
+ [UIApplication sharedApplication].scheduledLocalNotifications = @[];
608
613
 
609
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
610
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
614
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
615
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
611
616
  }
612
617
 
613
618
  - (void)getLaunchNotification:(CDVInvokedUrlCommand *)command {
614
- NSDictionary *startPush = self.startPushCleared ? nil : self.startPushData;
615
- CDVPluginResult *pluginResult =
616
- [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:startPush];
617
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
619
+ NSDictionary *startPush = self.startPushCleared ? nil : self.startPushData;
620
+ CDVPluginResult *pluginResult =
621
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:startPush];
622
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
618
623
  }
619
624
 
620
625
  - (void)clearLaunchNotification:(CDVInvokedUrlCommand *)command {
621
- self.startPushCleared = YES;
622
-
623
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
624
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
626
+ self.startPushCleared = YES;
627
+
628
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
629
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
625
630
  }
626
631
 
627
632
  - (void)setUserId:(CDVInvokedUrlCommand *)command {
@@ -877,54 +882,54 @@ void pwplugin_didFailToRegisterForRemoteNotificationsWithError(id self, SEL _cmd
877
882
  }
878
883
 
879
884
  BOOL pwplugin_didRegisterUserNotificationSettings(id self, SEL _cmd, id application, id notificationSettings) {
880
- PushNotification *pushHandler = pw_PushNotificationPlugin;
881
-
882
- UIUserNotificationSettings *settings = notificationSettings;
883
-
884
- BOOL backgroundPush = NO;
885
- NSArray * backgroundModes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"];
886
- for(NSString *mode in backgroundModes) {
887
- if([mode isEqualToString:@"remote-notification"]) {
888
- backgroundPush = YES;
889
- break;
890
- }
891
- }
892
-
893
- if (settings.types == UIUserNotificationTypeNone && !backgroundPush) {
894
- NSMutableDictionary *results = [NSMutableDictionary dictionary];
895
- results[@"error"] = [NSString stringWithFormat:@"Push Notifications are disabled by user"];
896
-
897
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
898
- [pushHandler.commandDelegate sendPluginResult:pluginResult callbackId:pushHandler.callbackIds[@"registerDevice"]];
899
- }
900
-
901
- if([self respondsToSelector:@selector(application: pwplugin_didRegisterUserNotificationSettings:)]) {
902
- [self application:application pwplugin_didRegisterUserNotificationSettings:notificationSettings];
903
- }
904
-
905
- return YES;
885
+ PushNotification *pushHandler = pw_PushNotificationPlugin;
886
+
887
+ UIUserNotificationSettings *settings = notificationSettings;
888
+
889
+ BOOL backgroundPush = NO;
890
+ NSArray * backgroundModes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"];
891
+ for(NSString *mode in backgroundModes) {
892
+ if([mode isEqualToString:@"remote-notification"]) {
893
+ backgroundPush = YES;
894
+ break;
895
+ }
896
+ }
897
+
898
+ if (settings.types == UIUserNotificationTypeNone && !backgroundPush) {
899
+ NSMutableDictionary *results = [NSMutableDictionary dictionary];
900
+ results[@"error"] = [NSString stringWithFormat:@"Push Notifications are disabled by user"];
901
+
902
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
903
+ [pushHandler.commandDelegate sendPluginResult:pluginResult callbackId:pushHandler.callbackIds[@"registerDevice"]];
904
+ }
905
+
906
+ if([self respondsToSelector:@selector(application: pwplugin_didRegisterUserNotificationSettings:)]) {
907
+ [self application:application pwplugin_didRegisterUserNotificationSettings:notificationSettings];
908
+ }
909
+
910
+ return YES;
906
911
  }
907
912
 
908
913
  + (void) swizzleNotificationSettingsHandler {
909
- if ([UIApplication sharedApplication].delegate == nil) {
910
- return;
911
- }
912
-
913
- if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) {
914
- return;
915
- }
916
-
917
- static Class appDelegateClass = nil;
918
-
919
- //do not swizzle the same class twice
920
- id delegate = [UIApplication sharedApplication].delegate;
921
- if(appDelegateClass == [delegate class]) {
922
- return;
923
- }
924
-
925
- appDelegateClass = [delegate class];
926
-
927
- pushwoosh_swizzle([delegate class], @selector(application:didRegisterUserNotificationSettings:), @selector(application:pwplugin_didRegisterUserNotificationSettings:), (IMP)pwplugin_didRegisterUserNotificationSettings, "v@:::");
914
+ if ([UIApplication sharedApplication].delegate == nil) {
915
+ return;
916
+ }
917
+
918
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) {
919
+ return;
920
+ }
921
+
922
+ static Class appDelegateClass = nil;
923
+
924
+ //do not swizzle the same class twice
925
+ id delegate = [UIApplication sharedApplication].delegate;
926
+ if(appDelegateClass == [delegate class]) {
927
+ return;
928
+ }
929
+
930
+ appDelegateClass = [delegate class];
931
+
932
+ pushwoosh_swizzle([delegate class], @selector(application:didRegisterUserNotificationSettings:), @selector(application:pwplugin_didRegisterUserNotificationSettings:), (IMP)pwplugin_didRegisterUserNotificationSettings, "v@:::");
928
933
  pushwoosh_swizzle([delegate class], @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:), @selector(application:pwplugin_didRegisterWithDeviceToken:), (IMP)pwplugin_didRegisterWithDeviceToken, "v@:::");
929
934
  pushwoosh_swizzle([delegate class], @selector(application:didFailToRegisterForRemoteNotificationsWithError:), @selector(application:pwplugin_didFailToRegisterForRemoteNotificationsWithError:), (IMP)pwplugin_didFailToRegisterForRemoteNotificationsWithError, "v@:::");
930
935
  pushwoosh_swizzle([delegate class], @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:), @selector(application:pwplugin_didReceiveRemoteNotification:fetchCompletionHandler:), (IMP)pwplugin_didReceiveRemoteNotification, "v@::::");
@@ -960,8 +965,8 @@ BOOL pwplugin_didRegisterUserNotificationSettings(id self, SEL _cmd, id applicat
960
965
  }
961
966
 
962
967
  - (void)dealloc {
963
- self.pushManager = nil;
964
- self.startPushData = nil;
968
+ self.pushManager = nil;
969
+ self.startPushData = nil;
965
970
  }
966
971
 
967
972
  @end
@@ -969,7 +974,7 @@ BOOL pwplugin_didRegisterUserNotificationSettings(id self, SEL _cmd, id applicat
969
974
  @implementation UIApplication (InternalPushRuntime)
970
975
 
971
976
  - (BOOL)pushwooshUseRuntimeMagic {
972
- return YES;
977
+ return YES;
973
978
  }
974
979
 
975
980
  @end
@@ -92,4 +92,5 @@ export interface PushNotification {
92
92
  setUserEmails(userId: string, emails: string[], success?: () => void, fail?: (error: Error|string) => void): void;
93
93
  registerSMSNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
94
94
  registerWhatsappNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
95
+ setApiToken(apiToken: string): void;
95
96
  }
@@ -667,4 +667,8 @@ PushNotification.prototype.enableHuaweiPushNotifications = function() {
667
667
  exec(null, null, "PushNotification", "enableHuaweiPushNotifications", []);
668
668
  }
669
669
 
670
+ PushNotification.prototype.setApiToken = function(token) {
671
+ exec(null, null, "PushNotification", "setApiToken", [token]);
672
+ }
673
+
670
674
  module.exports = new PushNotification();