pushwoosh-cordova-plugin 8.3.50 → 8.3.52

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.50
17
+ cordova plugin add pushwoosh-cordova-plugin@8.3.52
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.50
23
+ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.52
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.50",
3
+ "version": "8.3.52",
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.50">
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.52">
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.44"/>
99
- <framework src="com.pushwoosh:pushwoosh-amazon:6.7.44"/>
100
- <framework src="com.pushwoosh:pushwoosh-firebase:6.7.44"/>
101
- <framework src="com.pushwoosh:pushwoosh-badge:6.7.44"/>
102
- <framework src="com.pushwoosh:pushwoosh-inbox:6.7.44"/>
103
- <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.44"/>
104
- <framework src="com.pushwoosh:pushwoosh-huawei:6.7.44"/>
98
+ <framework src="com.pushwoosh:pushwoosh:6.7.45"/>
99
+ <framework src="com.pushwoosh:pushwoosh-amazon:6.7.45"/>
100
+ <framework src="com.pushwoosh:pushwoosh-firebase:6.7.45"/>
101
+ <framework src="com.pushwoosh:pushwoosh-badge:6.7.45"/>
102
+ <framework src="com.pushwoosh:pushwoosh-inbox:6.7.45"/>
103
+ <framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.45"/>
104
+ <framework src="com.pushwoosh:pushwoosh-huawei:6.7.45"/>
105
105
  </platform>
106
106
 
107
107
  <!-- ios -->
@@ -143,8 +143,8 @@
143
143
  <source url="https://github.com/CocoaPods/Specs.git"/>
144
144
  </config>
145
145
  <pods use-frameworks="true">
146
- <pod name="PushwooshXCFramework" spec="6.11.3" />
147
- <pod name="PushwooshInboxUIXCFramework" spec="6.1.2" />
146
+ <pod name="PushwooshXCFramework" spec="7.0.2" />
147
+ <pod name="PushwooshInboxUIXCFramework" spec="7.0.2" />
148
148
  </pods>
149
149
  </podspec>
150
150
 
@@ -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.44" }
19
+ dependencies { implementation "com.pushwoosh:pushwoosh-calls:6.7.45" }
20
20
  if (callsSrc?.exists()) {
21
21
  android.sourceSets.main.java.srcDirs += callsSrc
22
22
  println "[${pluginId}] Added optional sources: ${callsSrc}"
@@ -864,6 +864,8 @@ public class PushNotifications extends CordovaPlugin {
864
864
  callbackContextMap.put("reject", new ArrayList<CallbackContext>());
865
865
  callbackContextMap.put("hangup", new ArrayList<CallbackContext>());
866
866
  callbackContextMap.put("voipPushPayload", new ArrayList<CallbackContext>());
867
+ callbackContextMap.put("voipDidCancelCall", new ArrayList<CallbackContext>());
868
+ callbackContextMap.put("voipDidFailToCancelCall", new ArrayList<CallbackContext>());
867
869
  }
868
870
 
869
871
  @Override
@@ -1,5 +1,7 @@
1
1
  package com.pushwoosh.plugin.pushnotifications.calls;
2
2
 
3
+ import android.content.Context;
4
+ import android.content.Intent;
3
5
  import android.os.Bundle;
4
6
 
5
7
  import androidx.annotation.NonNull;
@@ -7,7 +9,8 @@ import androidx.annotation.Nullable;
7
9
 
8
10
  import com.pushwoosh.calls.PushwooshVoIPMessage;
9
11
  import com.pushwoosh.calls.listener.CallEventListener;
10
- import com.pushwoosh.plugin.pushnotifications.PushNotifications;
12
+ import com.pushwoosh.internal.platform.AndroidPlatformModule;
13
+ import com.pushwoosh.internal.utils.PWLog;
11
14
 
12
15
  public class PWCordovaCallEventListener implements CallEventListener {
13
16
  private static final Object sCurrentCallLock = new Object();
@@ -19,6 +22,20 @@ public class PWCordovaCallEventListener implements CallEventListener {
19
22
  synchronized (sCurrentCallLock) {
20
23
  currentCallInfo = pushwooshVoIPMessage.getRawPayload();
21
24
  }
25
+
26
+ try {
27
+ Context context = AndroidPlatformModule.getApplicationContext();
28
+ Intent launchIntent = context != null ? context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()) : null;
29
+
30
+ if (launchIntent != null) {
31
+ launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
32
+ context.startActivity(launchIntent);
33
+ PWLog.info("PWCordovaCallEventListener", "Launched main activity for call");
34
+ }
35
+ } catch (Exception e) {
36
+ PWLog.error("PWCordovaCallEventListener", "Failed to launch activity", e);
37
+ }
38
+
22
39
  PushwooshCallsAdapter.onAnswer(pushwooshVoIPMessage);
23
40
  }
24
41
 
@@ -56,6 +73,19 @@ public class PWCordovaCallEventListener implements CallEventListener {
56
73
  //stub
57
74
  }
58
75
 
76
+ @Override
77
+ public void onCallCancelled(@NonNull PushwooshVoIPMessage pushwooshVoIPMessage) {
78
+ PushwooshCallsAdapter.onCallCancelled(pushwooshVoIPMessage);
79
+ synchronized (sCurrentCallLock) {
80
+ currentCallInfo = null;
81
+ }
82
+ }
83
+
84
+ @Override
85
+ public void onCallCancellationFailed(@Nullable String callId, @Nullable String reason) {
86
+ PushwooshCallsAdapter.onCallCancellationFailed(callId, reason);
87
+ }
88
+
59
89
  public static Bundle getCurrentCallInfo() {
60
90
  synchronized (sCurrentCallLock) {
61
91
  return currentCallInfo;
@@ -180,20 +180,38 @@ public class PushwooshCallsAdapter implements CallsAdapter {
180
180
  PushNotifications.emitVoipEvent("hangup", parseVoIPMessage(voIPMessage));
181
181
  }
182
182
 
183
- public static void onCreateIncomingConnection(Bundle bundle) {
183
+ public static void onCreateIncomingConnection(Bundle bundle) {
184
184
  PushwooshVoIPMessage voipMessage = new PushwooshVoIPMessage(bundle);
185
185
  PushNotifications.emitVoipEvent("voipPushPayload", parseVoIPMessage(voipMessage));
186
186
  }
187
187
 
188
+ public static void onCallCancelled(PushwooshVoIPMessage voIPMessage) {
189
+ PushNotifications.emitVoipEvent("voipDidCancelCall", parseVoIPMessage(voIPMessage));
190
+ }
191
+
192
+ public static void onCallCancellationFailed(String callId, String reason) {
193
+ org.json.JSONObject payload = new org.json.JSONObject();
194
+ try {
195
+ payload.put("callId", callId != null ? callId : "");
196
+ payload.put("reason", reason != null ? reason : "");
197
+ } catch (org.json.JSONException ignored) {}
198
+ PushNotifications.emitVoipEvent("voipDidFailToCancelCall", payload);
199
+ }
200
+
188
201
  private static org.json.JSONObject parseVoIPMessage(PushwooshVoIPMessage message) {
189
202
  org.json.JSONObject payload = new org.json.JSONObject();
190
203
  try {
191
204
  Bundle rawBundle = message.getRawPayload();
192
205
  org.json.JSONObject rawPayloadJson = JsonUtils.bundleToJsonWithUserData(rawBundle);
193
-
206
+
194
207
  payload.put("callerName", message.getCallerName())
208
+ .put("callId", message.getCallId())
195
209
  .put("rawPayload", rawPayloadJson)
196
210
  .put("hasVideo", message.getHasVideo());
211
+
212
+ if (rawBundle != null && rawBundle.containsKey("handleType")) {
213
+ payload.put("handleType", rawBundle.get("handleType"));
214
+ }
197
215
  } catch (org.json.JSONException ignored) {}
198
216
  return payload;
199
217
  }
package/src/ios/PWLog.h CHANGED
@@ -1,25 +1,19 @@
1
1
  //
2
2
  // PWLog.h
3
3
  // Pushwoosh SDK
4
- // (c) Pushwoosh 2016
4
+ // (c) Pushwoosh 2025
5
5
  //
6
+ // Using PushwooshCore logging
6
7
 
7
8
  #import <Foundation/Foundation.h>
8
9
 
9
- typedef NS_ENUM(unsigned int, LogLevel) {
10
- kLogNone = 0,
11
- kLogError,
12
- kLogWarning,
13
- kLogInfo,
14
- kLogDebug,
15
- kLogVerbose
16
- };
10
+ // Logging macros using NSLog
11
+ #define PWLog(fmt, ...) NSLog(@"[Pushwoosh] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
12
+ #define PWLogError(fmt, ...) NSLog(@"[Pushwoosh ERROR] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
13
+ #define PWLogWarn(fmt, ...) NSLog(@"[Pushwoosh WARN] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
14
+ #define PWLogInfo(fmt, ...) NSLog(@"[Pushwoosh INFO] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
15
+ #define PWLogDebug(fmt, ...) NSLog(@"[Pushwoosh DEBUG] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
16
+ #define PWLogVerbose(fmt, ...) NSLog(@"[Pushwoosh VERBOSE] %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
17
17
 
18
- #define PWLog(...) PWLogInternal(__FUNCTION__, kLogInfo, __VA_ARGS__)
19
- #define PWLogError(...) PWLogInternal(__FUNCTION__, kLogError, __VA_ARGS__)
20
- #define PWLogWarn(...) PWLogInternal(__FUNCTION__, kLogWarning, __VA_ARGS__)
21
- #define PWLogInfo(...) PWLogInternal(__FUNCTION__, kLogInfo, __VA_ARGS__)
22
- #define PWLogDebug(...) PWLogInternal(__FUNCTION__, kLogDebug, __VA_ARGS__)
23
- #define PWLogVerbose(...) PWLogInternal(__FUNCTION__, kLogVerbose, __VA_ARGS__)
24
-
25
- void PWLogInternal(const char *function, LogLevel logLevel, NSString *format, ...);
18
+ // Backward compatibility
19
+ #define PWLogInternal(func, level, fmt, ...) NSLog(@"[Pushwoosh] %s: " fmt, func, ##__VA_ARGS__)
@@ -13,7 +13,7 @@
13
13
  #import "PushNotification.h"
14
14
  #import "PWLog.h"
15
15
  #import <PushwooshInboxUI/PushwooshInboxUI.h>
16
- #import <PushwooshFramework/PWInAppManager.h>
16
+ #import <PushwooshCore/PWInAppManager.h>
17
17
  #import <PushwooshFramework/PushNotificationManager.h>
18
18
  #import <PushwooshFramework/PWInbox.h>
19
19
  #import "PWBackward.h"
@@ -34,7 +34,6 @@
34
34
 
35
35
  #import <objc/runtime.h>
36
36
 
37
-
38
37
  #define WRITEJS(VAL) [NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", VAL]
39
38
  #define PW_COMMUNICATION_ENABLED_KEY @"PushwooshCommunicationEnabled"
40
39
  #define PW_COMMUNICATION_ENABLED_PLIST_KEY @"Pushwoosh_ALLOW_SERVER_COMMUNICATION"
@@ -121,7 +120,7 @@ API_AVAILABLE(ios(10))
121
120
  - (void)pluginInitialize {
122
121
  [super pluginInitialize];
123
122
  pw_PushNotificationPlugin = self;
124
-
123
+
125
124
  #if PW_VOIP_ENABLED
126
125
  callbackIds = [[NSMutableDictionary alloc] initWithCapacity:5];
127
126
  [callbackIds setObject:[NSMutableArray array] forKey:@"initializeVoIPParameters"];
@@ -139,6 +138,13 @@ API_AVAILABLE(ios(10))
139
138
  [callbackIds setObject:[NSMutableArray array] forKey:@"playDTMF"];
140
139
  [callbackIds setObject:[NSMutableArray array] forKey:@"voipDidFailToRegisterTokenWithError"];
141
140
  [callbackIds setObject:[NSMutableArray array] forKey:@"voipDidRegisterTokenSuccessfully"];
141
+ [callbackIds setObject:[NSMutableArray array] forKey:@"voipDidCancelCall"];
142
+ [callbackIds setObject:[NSMutableArray array] forKey:@"voipDidFailToCancelCall"];
143
+
144
+ // Set delegate early so VoIP events work even before initializeVoIPParameters is called
145
+ if (@available(iOS 14.0, *)) {
146
+ PushwooshVoIPImplementation.delegate = self;
147
+ }
142
148
 
143
149
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCallFromRecents:) name:@"RecentsCallNotification" object:nil];
144
150
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];
@@ -182,7 +188,7 @@ API_AVAILABLE(ios(10))
182
188
 
183
189
  - (void)setApiToken:(CDVInvokedUrlCommand *)command {
184
190
  NSString *token = command.arguments[0];
185
- [[PWSettings settings] setApiToken:token];
191
+ [[PWPreferences preferences] setApiToken:token];
186
192
  }
187
193
 
188
194
  - (void)onDeviceReady:(CDVInvokedUrlCommand *)command {
@@ -756,7 +762,7 @@ API_AVAILABLE(ios(10.0)) {
756
762
  if(callbackIds[eventName] != nil) {
757
763
  [callbackIds[eventName] addObject:command.callbackId];
758
764
  }
759
-
765
+
760
766
  if (pendingCallFromRecents && [eventName isEqual:@"sendCall"]) {
761
767
  NSDictionary *callData = pendingCallFromRecents;
762
768
  CDVPluginResult* pluginResult = nil;
@@ -900,6 +906,29 @@ API_AVAILABLE(ios(10.0)) {
900
906
  }
901
907
  }
902
908
 
909
+ // MARK: - voipDidCancelCall callback
910
+ - (void)voipDidCancelCallWithVoipMessage:(PWVoIPMessage *)voipMessage {
911
+ for (id callbackId in callbackIds[@"voipDidCancelCall"]) {
912
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:voipMessage]];
913
+ [pluginResult setKeepCallbackAsBool:YES];
914
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
915
+ }
916
+ }
917
+
918
+ // MARK: - voipDidFailToCancelCall callback
919
+ - (void)voipDidFailToCancelCallWithCallId:(NSString *)callId reason:(NSString *)reason {
920
+ for (id callbackId in callbackIds[@"voipDidFailToCancelCall"]) {
921
+ CDVPluginResult* pluginResult = nil;
922
+ NSDictionary *failureData = @{
923
+ @"callId": callId ?: @"",
924
+ @"reason": reason ?: @"Unknown reason"
925
+ };
926
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:failureData];
927
+ [pluginResult setKeepCallbackAsBool:YES];
928
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
929
+ }
930
+ }
931
+
903
932
  // MARK: - Answer Call
904
933
  - (void)answerCall:(CXProvider *)provider perform:(CXAnswerCallAction *)action voipMessage:(PWVoIPMessage *)voipMessage {
905
934
  [self setupAudioSession];
@@ -1020,6 +1049,8 @@ API_AVAILABLE(ios(10.0)) {
1020
1049
  [payload addEntriesFromDictionary:@{@"callerName": voipMessage.callerName}];
1021
1050
  [payload addEntriesFromDictionary:@{@"handleType": @(voipMessage.handleType)}];
1022
1051
  [payload addEntriesFromDictionary:@{@"hasVideo": @(voipMessage.hasVideo)}];
1052
+ [payload addEntriesFromDictionary:@{@"callId": voipMessage.callId ?: @""}];
1053
+ [payload addEntriesFromDictionary:@{@"cancelCall": @(voipMessage.cancelCall)}];
1023
1054
  return payload;
1024
1055
  }
1025
1056
  #endif
@@ -506,6 +506,8 @@ PushNotification.prototype.notificationCallback = function(notification) {
506
506
  * - "playDTMF": Triggered when a DTMF tone is played.
507
507
  * - "voipDidFailToRegisterTokenWithError": Triggered when VoIP token registration fails (iOS only).
508
508
  * - "voipDidRegisterTokenSuccessfully": Triggered when VoIP token registration succeeds (iOS only).
509
+ * - "voipDidCancelCall": Triggered when a call is remotely cancelled via VoIP push.
510
+ * - "voipDidFailToCancelCall": Triggered when a call cancellation attempt fails.
509
511
  *
510
512
  * @param {Function} success - Callback function to be invoked when the event occurs.
511
513
  * @param {Function} fail - Callback function to be invoked if the registration fails.
@@ -534,6 +536,8 @@ PushNotification.prototype.registerEvent = function(eventName, success, fail) {
534
536
  * - "playDTMF": Triggered when a DTMF tone is played.
535
537
  * - "voipDidFailToRegisterTokenWithError": Triggered when VoIP token registration fails (iOS only).
536
538
  * - "voipDidRegisterTokenSuccessfully": Triggered when VoIP token registration succeeds (iOS only).
539
+ * - "voipDidCancelCall": Triggered when a call is remotely cancelled via VoIP push.
540
+ * - "voipDidFailToCancelCall": Triggered when a call cancellation attempt fails.
537
541
  *
538
542
  * @param {Function} success - Callback function to be invoked when the event is successfully unregistered.
539
543
  * @param {Function} fail - Callback function to be invoked if the unregistration fails.