pushwoosh-cordova-plugin 8.3.53 → 8.3.55

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:
15
15
 
16
16
  ```
17
- cordova plugin add pushwoosh-cordova-plugin@8.3.53
17
+ cordova plugin add pushwoosh-cordova-plugin@8.3.55
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.53
23
+ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.55
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.53",
3
+ "version": "8.3.55",
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.53">
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.55">
3
3
 
4
4
  <name>Pushwoosh</name>
5
5
 
@@ -95,13 +95,13 @@
95
95
  <framework src="org.jetbrains.kotlin:kotlin-stdlib:1.1.60" />
96
96
  <framework src="com.google.android.material:material:1.12.0"/>
97
97
 
98
- <framework src="com.pushwoosh:pushwoosh:6.7.46"/>
99
- <framework src="com.pushwoosh:pushwoosh-amazon:6.7.46"/>
100
- <framework src="com.pushwoosh:pushwoosh-firebase:6.7.46"/>
101
- <framework src="com.pushwoosh:pushwoosh-badge:6.7.46"/>
102
- <framework src="com.pushwoosh:pushwoosh-inbox:6.7.46"/>
103
- <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.46"/>
104
- <framework src="com.pushwoosh:pushwoosh-huawei:6.7.46"/>
98
+ <framework src="com.pushwoosh:pushwoosh:6.7.47"/>
99
+ <framework src="com.pushwoosh:pushwoosh-amazon:6.7.47"/>
100
+ <framework src="com.pushwoosh:pushwoosh-firebase:6.7.47"/>
101
+ <framework src="com.pushwoosh:pushwoosh-badge:6.7.47"/>
102
+ <framework src="com.pushwoosh:pushwoosh-inbox:6.7.47"/>
103
+ <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.47"/>
104
+ <framework src="com.pushwoosh:pushwoosh-huawei:6.7.47"/>
105
105
  </platform>
106
106
 
107
107
  <!-- ios -->
@@ -143,7 +143,7 @@
143
143
  <source url="https://github.com/CocoaPods/Specs.git"/>
144
144
  </config>
145
145
  <pods use-frameworks="true">
146
- <pod name="PushwooshXCFramework" spec="7.0.3" />
146
+ <pod name="PushwooshXCFramework" spec="7.0.4" />
147
147
  <pod name="PushwooshInboxUIXCFramework" spec="7.0.3" />
148
148
  </pods>
149
149
  </podspec>
@@ -16,7 +16,7 @@ def callsSrc = pluginDir ? new File(pluginDir, 'src/android/src/com/pushwoosh/pl
16
16
  def applyVoip = {
17
17
  if (voipEnabled) {
18
18
  println "[${pluginId}] PW_VOIP_ANDROID_ENABLED=true — enabling VoIP (dependency + sources)"
19
- dependencies { implementation "com.pushwoosh:pushwoosh-calls:6.7.46" }
19
+ dependencies { implementation "com.pushwoosh:pushwoosh-calls:6.7.47" }
20
20
  if (callsSrc?.exists()) {
21
21
  android.sourceSets.main.java.srcDirs += callsSrc
22
22
  println "[${pluginId}] Added optional sources: ${callsSrc}"
@@ -11,6 +11,7 @@ public interface CallsAdapter {
11
11
  public boolean unregisterEvent(JSONArray data, final CallbackContext callbackContext);
12
12
  public boolean endCall(JSONArray data, final CallbackContext callbackContext);
13
13
  public boolean initializeVoIPParameters(JSONArray data, final CallbackContext callbackContext);
14
+ public boolean setIncomingCallTimeout(JSONArray data, final CallbackContext callbackContext);
14
15
  public boolean mute();
15
16
  public boolean unmute();
16
17
  public boolean speakerOn();
@@ -49,6 +49,12 @@ public class NoopCallsAdapter implements CallsAdapter{
49
49
  return false;
50
50
  }
51
51
 
52
+ @Override
53
+ public boolean setIncomingCallTimeout(JSONArray data, CallbackContext callbackContext) {
54
+ PWLog.error(TAG,"Method not implemented");
55
+ return false;
56
+ }
57
+
52
58
  @Override
53
59
  public boolean mute() {
54
60
  PWLog.error(TAG,"Method not implemented");
@@ -1103,6 +1103,11 @@ public class PushNotifications extends CordovaPlugin {
1103
1103
  return callsAdapter.initializeVoIPParameters(data, callbackContext);
1104
1104
  }
1105
1105
 
1106
+ @CordovaMethod
1107
+ private boolean setIncomingCallTimeout(JSONArray data, final CallbackContext callbackContext) {
1108
+ return callsAdapter.setIncomingCallTimeout(data, callbackContext);
1109
+ }
1110
+
1106
1111
  @CordovaMethod
1107
1112
  private boolean mute() {
1108
1113
  return callsAdapter.mute();
@@ -9,6 +9,7 @@ import android.media.AudioManager;
9
9
  import android.os.Bundle;
10
10
 
11
11
  import com.pushwoosh.Pushwoosh;
12
+ import com.pushwoosh.calls.CallPermissionsCallback;
12
13
  import com.pushwoosh.calls.PushwooshCallReceiver;
13
14
  import com.pushwoosh.calls.PushwooshCallSettings;
14
15
  import com.pushwoosh.calls.PushwooshVoIPMessage;
@@ -40,11 +41,17 @@ public class PushwooshCallsAdapter implements CallsAdapter {
40
41
  }
41
42
 
42
43
  @Override
43
- public boolean requestCallPermission(JSONArray data, CallbackContext callbackContext) {
44
+ public boolean requestCallPermission(JSONArray data, final CallbackContext callbackContext) {
44
45
  try {
45
- PushwooshCallSettings.requestCallPermissions();
46
+ PushwooshCallSettings.requestCallPermissions(new CallPermissionsCallback() {
47
+ @Override
48
+ public void onPermissionResult(boolean granted, java.util.List<String> grantedPerms, java.util.List<String> deniedPerms) {
49
+ callbackContext.success(granted ? 1 : 0);
50
+ }
51
+ });
46
52
  } catch (Exception e) {
47
53
  PWLog.error(TAG, "Failed to request call permissions: " + e.getMessage());
54
+ callbackContext.error("Failed to request call permissions: " + e.getMessage());
48
55
  return false;
49
56
  }
50
57
  return true;
@@ -120,6 +127,18 @@ public class PushwooshCallsAdapter implements CallsAdapter {
120
127
  }
121
128
  }
122
129
 
130
+ @Override
131
+ public boolean setIncomingCallTimeout(JSONArray data, CallbackContext callbackContext) {
132
+ try {
133
+ double timeout = data.getDouble(0);
134
+ PushwooshCallSettings.setIncomingCallTimeout(timeout);
135
+ return true;
136
+ } catch (Exception e) {
137
+ PWLog.error("Failed to set incoming call timeout: " + e.getMessage());
138
+ return false;
139
+ }
140
+ }
141
+
123
142
  @Override
124
143
  public boolean mute() {
125
144
  try {
@@ -634,7 +634,9 @@ API_AVAILABLE(ios(10.0)) {
634
634
  #if PW_VOIP_ENABLED
635
635
  // MARK: - Voip settings
636
636
  - (void)requestCallPermission:(CDVInvokedUrlCommand *)command {
637
- //stub, android only
637
+ //stub, android only - iOS doesn't require call permission
638
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
639
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
638
640
  }
639
641
 
640
642
  - (void)getCallPermissionStatus:(CDVInvokedUrlCommand *)command {
@@ -725,6 +727,28 @@ API_AVAILABLE(ios(10.0)) {
725
727
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
726
728
  }
727
729
 
730
+ // MARK: - Set Incoming Call Timeout
731
+ - (void)setIncomingCallTimeout:(CDVInvokedUrlCommand *)command {
732
+ CDVPluginResult* pluginResult = nil;
733
+
734
+ NSNumber *timeoutNumber = [command.arguments objectAtIndex:0];
735
+
736
+ if ([timeoutNumber isKindOfClass:[NSNumber class]]) {
737
+ NSTimeInterval timeout = [timeoutNumber doubleValue];
738
+
739
+ if (@available(iOS 14.0, *)) {
740
+ [PushwooshVoIPImplementation setIncomingCallTimeout:timeout];
741
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Incoming call timeout set"];
742
+ } else {
743
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"VoIP requires iOS 14.0 or later"];
744
+ }
745
+ } else {
746
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid timeout parameter"];
747
+ }
748
+
749
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
750
+ }
751
+
728
752
  // MARK: - Incoming Call Payload
729
753
  - (void)voipDidReceiveIncomingCallWithPayload:(PWVoIPMessage *)payload {
730
754
  for (id callbackId in callbackIds[@"voipPushPayload"]) {
@@ -1330,16 +1354,40 @@ void pwplugin_didRegisterWithDeviceToken(id self, SEL _cmd, id application, NSDa
1330
1354
  if ([self respondsToSelector:@selector(application: pwplugin_didRegisterWithDeviceToken:)]) {
1331
1355
  [self application:application pwplugin_didRegisterWithDeviceToken:deviceToken];
1332
1356
  }
1333
-
1357
+
1334
1358
  [[Pushwoosh sharedInstance] handlePushRegistration:deviceToken];
1359
+
1360
+ PushNotification *pushHandler = pw_PushNotificationPlugin;
1361
+ if (pushHandler && pushHandler.callbackIds[@"registerDevice"]) {
1362
+ const unsigned char *tokenBytes = (const unsigned char *)[deviceToken bytes];
1363
+ NSMutableString *token = [NSMutableString string];
1364
+ for (NSInteger i = 0; i < [deviceToken length]; i++) {
1365
+ [token appendFormat:@"%02x", (unsigned int)tokenBytes[i]];
1366
+ }
1367
+
1368
+ NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
1369
+ results[@"pushToken"] = token;
1370
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
1371
+ [pushHandler.commandDelegate sendPluginResult:pluginResult callbackId:pushHandler.callbackIds[@"registerDevice"]];
1372
+ pushHandler.callbackIds[@"registerDevice"] = nil;
1373
+ }
1335
1374
  }
1336
1375
 
1337
1376
  void pwplugin_didFailToRegisterForRemoteNotificationsWithError(id self, SEL _cmd, UIApplication *application, NSError *error) {
1338
1377
  if ([self respondsToSelector:@selector(application:pwplugin_didFailToRegisterForRemoteNotificationsWithError:)]) {
1339
1378
  [self application:application pwplugin_didFailToRegisterForRemoteNotificationsWithError:error];
1340
1379
  }
1341
-
1380
+
1342
1381
  [[Pushwoosh sharedInstance] handlePushRegistrationFailure:error];
1382
+
1383
+ PushNotification *pushHandler = pw_PushNotificationPlugin;
1384
+ if (pushHandler && pushHandler.callbackIds[@"registerDevice"]) {
1385
+ NSMutableDictionary *results = [NSMutableDictionary dictionary];
1386
+ results[@"error"] = [NSString stringWithFormat:@"%@", error];
1387
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:results];
1388
+ [pushHandler.commandDelegate sendPluginResult:pluginResult callbackId:pushHandler.callbackIds[@"registerDevice"]];
1389
+ pushHandler.callbackIds[@"registerDevice"] = nil;
1390
+ }
1343
1391
  }
1344
1392
 
1345
1393
  BOOL pwplugin_didRegisterUserNotificationSettings(id self, SEL _cmd, id application, id notificationSettings) {
@@ -28,6 +28,7 @@ type InboxNotification = {
28
28
  isActionPerformed?: boolean;
29
29
  }
30
30
 
31
+
31
32
  type AuthOptions = Record<string, number|string>
32
33
 
33
34
  type RemoteNotificationStatus = Record<string,string|number|boolean>
@@ -95,7 +96,7 @@ export interface PushNotification {
95
96
  speakerOff(success?: () => void, error?: (err: Error | string) => void): void;
96
97
  mute(success?: () => void, error?: (err: Error | string) => void): void;
97
98
  unmute(success?: () => void, error?: (err: Error | string) => void): void;
98
- requestCallPermission(): void;
99
+ requestCallPermission(success?: (granted: boolean) => void, error?: (err: Error | string) => void): void;
99
100
  getCallPermissionStatus(success?: (status: number) => void, error?: (err: Error | string) => void): void;
100
101
  endCall(success?: () => void, error?: (err: Error | string) => void): void;
101
102
  }
@@ -641,9 +641,11 @@ PushNotification.prototype.unmute = function(success, error) {
641
641
  // Android calls
642
642
  /**
643
643
  * Request call permission and register phone account
644
+ * @param {Function} success - Callback invoked with permission result
645
+ * @param {Function} error - Callback invoked if the operation fails
644
646
  */
645
- PushNotification.prototype.requestCallPermission = function() {
646
- exec(null, null, "PushNotification", "requestCallPermission", []);
647
+ PushNotification.prototype.requestCallPermission = function(success, error) {
648
+ exec(success, error, "PushNotification", "requestCallPermission", []);
647
649
  }
648
650
 
649
651
  /**
@@ -833,4 +835,8 @@ PushNotification.prototype.setVoipAppCode = function(appCode) {
833
835
  exec(null, null, "PushNotification", "setVoipAppCode", [appCode]);
834
836
  }
835
837
 
838
+ PushNotification.prototype.setIncomingCallTimeout = function(timeoutSeconds) {
839
+ exec(null, null, "PushNotification", "setIncomingCallTimeout", [timeoutSeconds]);
840
+ }
841
+
836
842
  module.exports = new PushNotification();