Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 15.2.0 #428

Merged
merged 7 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion cordova-airship-hms/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 3 additions & 6 deletions cordova-airship-hms/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-airship-hms"
version="15.1.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">

<plugin id="@ua/cordova-airship-hms" version="15.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">

<name>Airship HMS</name>
<description>Airship HMS Cordova plugin</description>
<license>Apache 2.0</license>
Expand All @@ -15,7 +12,7 @@
<engine name="cordova" version=">=9.0.1"/>
</engines>

<dependency id="@ua/cordova-airship" version="15.1.0"/>
<dependency id="@ua/cordova-airship" version="15.2.0"/>

<!-- android -->
<platform name="android">
Expand Down
4 changes: 2 additions & 2 deletions cordova-airship/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cordova-airship/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 3 additions & 6 deletions cordova-airship/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="@ua/cordova-airship"
version="15.1.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">

<plugin id="@ua/cordova-airship" version="15.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">

<name>Airship</name>
<description>Airship Cordova plugin</description>
<license>Apache 2.0</license>
Expand Down Expand Up @@ -133,7 +130,7 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="AirshipFrameworkProxy" spec="6.0.0" />
<pod name="AirshipFrameworkProxy" spec="6.1.1" />
</pods>
</podspec>
</platform>
Expand Down
26 changes: 6 additions & 20 deletions cordova-airship/src/android/AirshipCordova.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AirshipCordova : CordovaPlugin() {
val callbackContext: CallbackContext
)

private var listeners: MutableMap<EventType, MutableList<Listener>> = mutableMapOf()
private var listeners: MutableMap<String, MutableList<Listener>> = mutableMapOf()

companion object {
private val EVENT_NAME_MAP = mapOf(
Expand All @@ -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"
)
}
Expand Down Expand Up @@ -103,44 +103,30 @@ 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to map to types, instead only use the map when finding the listener. This fixes background response and makes it so we can combine foreground/background push received

notifyPendingEvents()
}

private fun removeListener(args: JSONArray) {
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 ->
Expand Down Expand Up @@ -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?)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do not set a value on Android cordova it will set the value based on the status message.

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))
Expand Down
2 changes: 1 addition & 1 deletion cordova-airship/src/android/AirshipCordovaVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
package com.urbanairship.cordova

object AirshipCordovaVersion {
var version = "15.1.0"
var version = "15.2.0"
}
2 changes: 1 addition & 1 deletion cordova-airship/src/android/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
19 changes: 1 addition & 18 deletions cordova-airship/src/ios/AirshipCordova.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -595,7 +589,6 @@ extension CDVInvokedUrlCommand {
return try args.map { try parse($0) }
}


func requireStringArrayArg() throws -> [String] {
guard
self.arguments.count >= 2,
Expand Down Expand Up @@ -629,7 +622,6 @@ extension CDVInvokedUrlCommand {
}

func requireStringArg() throws -> String {

guard
self.arguments.count >= 2,
let args = self.arguments[1] as? String
Expand Down Expand Up @@ -661,7 +653,6 @@ extension CDVInvokedUrlCommand {
func requireDoubleArg() throws -> Double {
let value = try requireAnyArg()


if let double = value as? Double {
return double
}
Expand All @@ -674,7 +665,6 @@ extension CDVInvokedUrlCommand {
return number.doubleValue
}


throw AirshipErrors.error("Argument must be a double")
}
}
Expand Down Expand Up @@ -708,10 +698,3 @@ extension AirshipProxyEventEmitter {
}
}
}

public struct CodableQuietTimeSettings: Codable {
let startHour: UInt
let startMinute: UInt
let endHour: UInt
let endMinute: UInt
}
2 changes: 1 addition & 1 deletion cordova-airship/src/ios/AirshipCordovaVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import Foundation

class AirshipCordovaVersion {
static let version = "15.1.0"
static let version = "15.2.0"
}
5 changes: 5 additions & 0 deletions cordova-airship/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
rlepinski marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
5 changes: 4 additions & 1 deletion scripts/update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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 '' '/<dependency id="@ua/cordova-airship" version="[^"]*"\/>/s/version="[^"]*"/version="'$VERSION'"/' $HMS_PLUGIN_XML_PATH
sed -i '' "s/<plugin id=\"@ua\/cordova-airship\" version=\"[0-9.]*\"/<plugin id=\"@ua\/cordova-airship\" version=\"$VERSION\"/" $CORE_PLUGIN_XML_PATH
sed -i '' "s/<plugin id=\"@ua\/cordova-airship-hms\" version=\"[0-9.]*\"/<plugin id=\"@ua\/cordova-airship-hms\" version=\"$VERSION\"/" $HMS_PLUGIN_XML_PATH
sed -i '' "s/<dependency id=\"@ua\/cordova-airship\" version=\"[0-9.]*\"\/>/<dependency id=\"@ua\/cordova-airship\" version=\"$VERSION\"\/>/" $HMS_PLUGIN_XML_PATH
npm --prefix $CORE_PACKAGE_PATH version $VERSION
npm --prefix $HMS_PACKAGE_PATH version $VERSION