diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3fa54e..03dcfbff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Cordova Plugin Changelog +## Version 15.2.0 April 23, 2024 +Minor release with several bug fixes. + +### Changes +- Added `isForeground` to push received events to indicate the application state when the push was received. +- Fixed cordova-airship-hms plugin ID mismatch. +- Fixed Android background push received and background notification response events. +- Fixed null result handling on Android to be null instead of the OK status. +- Updated iOS SDK to 18.1.1 + ## Version 15.1.0 April 18, 2024 Minor release with several bug fixes. diff --git a/cordova-airship-hms/package.json b/cordova-airship-hms/package.json index e40d041a..2ee28c49 100644 --- a/cordova-airship-hms/package.json +++ b/cordova-airship-hms/package.json @@ -1,6 +1,6 @@ { "name": "@ua/cordova-airship-hms", - "version": "15.1.0", + "version": "15.2.0", "description": "Airship HMS Cordova plugin", "cordova": { "id": "@ua/cordova-airship-hms", diff --git a/cordova-airship-hms/plugin.xml b/cordova-airship-hms/plugin.xml index 434adfbb..12aeea18 100644 --- a/cordova-airship-hms/plugin.xml +++ b/cordova-airship-hms/plugin.xml @@ -1,9 +1,6 @@ - - + + Airship HMS Airship HMS Cordova plugin Apache 2.0 @@ -15,7 +12,7 @@ - + diff --git a/cordova-airship/package-lock.json b/cordova-airship/package-lock.json index 050e5c43..80c20dbf 100644 --- a/cordova-airship/package-lock.json +++ b/cordova-airship/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ua/cordova-airship", - "version": "15.0.0", + "version": "15.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ua/cordova-airship", - "version": "15.0.0", + "version": "15.2.0", "engines": [ { "name": "cordova-android", diff --git a/cordova-airship/package.json b/cordova-airship/package.json index 12338e7f..49d7b033 100644 --- a/cordova-airship/package.json +++ b/cordova-airship/package.json @@ -1,6 +1,6 @@ { "name": "@ua/cordova-airship", - "version": "15.1.0", + "version": "15.2.0", "description": "Airship Cordova plugin", "cordova": { "id": "@ua/cordova-airship", diff --git a/cordova-airship/plugin.xml b/cordova-airship/plugin.xml index 2a9f2c47..8d1bd9d1 100644 --- a/cordova-airship/plugin.xml +++ b/cordova-airship/plugin.xml @@ -1,9 +1,6 @@ - - + + Airship Airship Cordova plugin Apache 2.0 @@ -133,7 +130,7 @@ - + diff --git a/cordova-airship/src/android/AirshipCordova.kt b/cordova-airship/src/android/AirshipCordova.kt index b2e92ff5..45048222 100644 --- a/cordova-airship/src/android/AirshipCordova.kt +++ b/cordova-airship/src/android/AirshipCordova.kt @@ -36,7 +36,7 @@ class AirshipCordova : CordovaPlugin() { val callbackContext: CallbackContext ) - private var listeners: MutableMap> = mutableMapOf() + private var listeners: MutableMap> = mutableMapOf() companion object { private val EVENT_NAME_MAP = mapOf( @@ -49,7 +49,7 @@ class AirshipCordova : CordovaPlugin() { EventType.MESSAGE_CENTER_UPDATED to "airship.event.message_center_updated", EventType.PUSH_TOKEN_RECEIVED to "airship.event.push_token_received", EventType.FOREGROUND_PUSH_RECEIVED to "airship.event.push_received", - EventType.BACKGROUND_PUSH_RECEIVED to "airship.event.background_push_received", + EventType.BACKGROUND_PUSH_RECEIVED to "airship.event.push_received", EventType.NOTIFICATION_STATUS_CHANGED to "airship.event.notification_status_changed" ) } @@ -103,20 +103,13 @@ class AirshipCordova : CordovaPlugin() { val jsonArgs = JsonValue.wrap(args).requireList() val eventName = jsonArgs.get(0).requireString() - val event: EventType = EVENT_NAME_MAP.firstNotNullOf { - if (it.value == eventName) { - it.key - } else { - null - } - } val listener = Listener( listenerId = jsonArgs.get(1).requireInt(), callbackContext = callbackContext ) - this.listeners.getOrPut(event) { mutableListOf() }.add(listener) + this.listeners.getOrPut(eventName) { mutableListOf() }.add(listener) notifyPendingEvents() } @@ -124,23 +117,16 @@ class AirshipCordova : CordovaPlugin() { val jsonArgs = JsonValue.wrap(args).requireList() val eventName = jsonArgs.get(0).requireString() - val event: EventType = EVENT_NAME_MAP.firstNotNullOf { - if (it.value == eventName) { - it.key - } else { - null - } - } val listenerId = jsonArgs.get(1).requireInt() - this.listeners[event]?.removeAll { + this.listeners[eventName]?.removeAll { it.listenerId == listenerId } } private fun notifyPendingEvents() { EventType.values().forEach { eventType -> - val listeners = this.listeners[eventType] + val listeners = this.listeners[EVENT_NAME_MAP[eventType]] if (listeners?.isNotEmpty() == true) { EventEmitter.shared().processPending(listOf(eventType)) { event -> listeners.forEach { listeners -> @@ -396,7 +382,7 @@ internal fun JsonSerializable.pluginResult(): PluginResult { val json = this.toJsonValue() return when { - json.isNull -> PluginResult(PluginResult.Status.OK) + json.isNull -> PluginResult(PluginResult.Status.OK, null as String?) json.isString -> PluginResult(PluginResult.Status.OK, json.requireString()) json.isBoolean -> PluginResult(PluginResult.Status.OK, json.requireBoolean()) json.isInteger -> PluginResult(PluginResult.Status.OK, json.getInt(0)) diff --git a/cordova-airship/src/android/AirshipCordovaVersion.kt b/cordova-airship/src/android/AirshipCordovaVersion.kt index 83fe5bac..05f4d3c7 100644 --- a/cordova-airship/src/android/AirshipCordovaVersion.kt +++ b/cordova-airship/src/android/AirshipCordovaVersion.kt @@ -3,5 +3,5 @@ package com.urbanairship.cordova object AirshipCordovaVersion { - var version = "15.1.0" + var version = "15.2.0" } \ No newline at end of file diff --git a/cordova-airship/src/android/build-extras.gradle b/cordova-airship/src/android/build-extras.gradle index e9466966..0972f4f2 100644 --- a/cordova-airship/src/android/build-extras.gradle +++ b/cordova-airship/src/android/build-extras.gradle @@ -1,5 +1,5 @@ dependencies { - api "com.urbanairship.android:airship-framework-proxy:6.0.0" + api "com.urbanairship.android:airship-framework-proxy:6.1.1" } cdvPluginPostBuildExtras.push({ diff --git a/cordova-airship/src/ios/AirshipCordova.swift b/cordova-airship/src/ios/AirshipCordova.swift index 1fc3ce1e..b2c6f51a 100644 --- a/cordova-airship/src/ios/AirshipCordova.swift +++ b/cordova-airship/src/ios/AirshipCordova.swift @@ -353,14 +353,8 @@ public final class AirshipCordova: CDVPlugin { return try AirshipProxy.shared.push.isQuietTimeEnabled() case "push#ios#setQuietTime": - let proxySettings: CodableQuietTimeSettings = try command.requireCodableArg() try AirshipProxy.shared.push.setQuietTime( - QuietTimeSettings( - startHour: proxySettings.startHour, - startMinute: proxySettings.startMinute, - endHour: proxySettings.endHour, - endMinute: proxySettings.endMinute - ) + try command.requireCodableArg() ) return nil @@ -595,7 +589,6 @@ extension CDVInvokedUrlCommand { return try args.map { try parse($0) } } - func requireStringArrayArg() throws -> [String] { guard self.arguments.count >= 2, @@ -629,7 +622,6 @@ extension CDVInvokedUrlCommand { } func requireStringArg() throws -> String { - guard self.arguments.count >= 2, let args = self.arguments[1] as? String @@ -661,7 +653,6 @@ extension CDVInvokedUrlCommand { func requireDoubleArg() throws -> Double { let value = try requireAnyArg() - if let double = value as? Double { return double } @@ -674,7 +665,6 @@ extension CDVInvokedUrlCommand { return number.doubleValue } - throw AirshipErrors.error("Argument must be a double") } } @@ -708,10 +698,3 @@ extension AirshipProxyEventEmitter { } } } - -public struct CodableQuietTimeSettings: Codable { - let startHour: UInt - let startMinute: UInt - let endHour: UInt - let endMinute: UInt -} diff --git a/cordova-airship/src/ios/AirshipCordovaVersion.swift b/cordova-airship/src/ios/AirshipCordovaVersion.swift index b177075b..83609186 100644 --- a/cordova-airship/src/ios/AirshipCordovaVersion.swift +++ b/cordova-airship/src/ios/AirshipCordovaVersion.swift @@ -3,5 +3,5 @@ import Foundation class AirshipCordovaVersion { - static let version = "15.1.0" + static let version = "15.2.0" } diff --git a/cordova-airship/types/index.d.ts b/cordova-airship/types/index.d.ts index 74a39ae1..06f47a9e 100644 --- a/cordova-airship/types/index.d.ts +++ b/cordova-airship/types/index.d.ts @@ -31,6 +31,11 @@ export interface PushTokenReceivedEvent { */ export interface PushReceivedEvent { pushPayload: PushPayload; + + /** + * Indicates whether the push was received when the application was in the background or foreground. + */ + isForeground: boolean; } /** diff --git a/scripts/update_version.sh b/scripts/update_version.sh index 100f67d0..a524feef 100755 --- a/scripts/update_version.sh +++ b/scripts/update_version.sh @@ -7,6 +7,7 @@ HMS_PACKAGE_PATH="$ROOT_PATH/cordova-airship-hms" ANDROID_VERISON_PATH="$ROOT_PATH/cordova-airship/src/android/AirshipCordovaVersion.kt" IOS_VERISON_PATH="$ROOT_PATH/cordova-airship/src/ios/AirshipCordovaVersion.swift" HMS_PLUGIN_XML_PATH="$ROOT_PATH/cordova-airship-hms/plugin.xml" +CORE_PLUGIN_XML_PATH="$ROOT_PATH/cordova-airship/plugin.xml" if [ -z "$1" ] @@ -18,6 +19,8 @@ fi sed -i '' "s/var version = \"[-0-9.a-zA-Z]*\"/var version = \"$VERSION\"/" $ANDROID_VERISON_PATH sed -i '' "s/static let version = \"[-0-9.a-zA-Z]*\"/static let version = \"$VERSION\"/" $IOS_VERISON_PATH -sed -i '' '//s/version="[^"]*"/version="'$VERSION'"/' $HMS_PLUGIN_XML_PATH +sed -i '' "s///" $HMS_PLUGIN_XML_PATH npm --prefix $CORE_PACKAGE_PATH version $VERSION npm --prefix $HMS_PACKAGE_PATH version $VERSION \ No newline at end of file