Skip to content

Commit

Permalink
Apple platform fixes (#337)
Browse files Browse the repository at this point in the history
* Fix issue with passing the device token
* Update PubNub Swift SDK dependency
* PubNub SDK v10.4.4 release
  • Loading branch information
jguz-pubnub authored Mar 7, 2025
1 parent c30e2f0 commit cf4bd64
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 70 deletions.
13 changes: 9 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: kotlin
version: 10.4.3
version: 10.4.4
schema: 1
scm: github.com/pubnub/kotlin
files:
- build/libs/pubnub-kotlin-10.4.3-all.jar
- build/libs/pubnub-kotlin-10.4.4-all.jar
sdks:
-
type: library
Expand All @@ -23,8 +23,8 @@ sdks:
-
distribution-type: library
distribution-repository: maven
package-name: pubnub-kotlin-10.4.3
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.4.3/pubnub-kotlin-10.4.3.jar
package-name: pubnub-kotlin-10.4.4
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.4.4/pubnub-kotlin-10.4.4.jar
supported-platforms:
supported-operating-systems:
Android:
Expand Down Expand Up @@ -121,6 +121,11 @@ sdks:
license-url: https://www.apache.org/licenses/LICENSE-2.0.txt
is-required: Required
changelog:
- date: 2025-03-07
version: v10.4.4
changes:
- type: bug
text: "Internal fixes."
- date: 2025-02-28
version: v10.4.3
changes:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v10.4.4
March 07 2025

#### Fixed
- Internal fixes.

## v10.4.3
February 28 2025

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-kotlin</artifactId>
<version>10.4.3</version>
<version>10.4.4</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RELEASE_SIGNING_ENABLED=true
SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
VERSION_NAME=10.4.3
VERSION_NAME=10.4.4
POM_PACKAGING=jar

POM_NAME=PubNub SDK
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dokka = "1.9.20"
kotlinx_datetime = "0.6.1"
kotlinx_coroutines = "1.9.0"
pubnub_js = "8.6.0"
pubnub_swift = "8.3.0"
pubnub_swift = "9.0.0"

[libraries]
retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit2" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push

import cocoapods.PubNubSwift.KMPPubNub
import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels
import com.pubnub.api.PubNubException
import com.pubnub.api.enums.PNPushEnvironment
import com.pubnub.api.enums.PNPushType
import com.pubnub.api.models.consumer.push.PNPushAddChannelResult
Expand All @@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
import com.pubnub.kmp.PNFuture
import com.pubnub.kmp.onFailureHandler
import com.pubnub.kmp.onSuccessHandler
import com.pubnub.kmp.toNSData
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData

/**
* @see [PubNub.addPushNotificationsOnChannels]
Expand All @@ -30,16 +27,14 @@ class AddChannelsToPushImpl(
private val environment: PNPushEnvironment
) : AddChannelsToPush {
override fun async(callback: Consumer<Result<PNPushAddChannelResult>>) {
deviceId.toNSData()?.let { data: NSData ->
pubnub.addChannelsToPushNotificationsWithChannels(
channels = channels,
deviceId = data,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() },
onFailure = callback.onFailureHandler()
)
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
pubnub.addChannelsToPushNotificationsWithChannels(
channels = channels,
deviceId = deviceId,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() },
onFailure = callback.onFailureHandler()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push

import cocoapods.PubNubSwift.KMPPubNub
import cocoapods.PubNubSwift.listPushChannelsWithDeviceId
import com.pubnub.api.PubNubException
import com.pubnub.api.enums.PNPushEnvironment
import com.pubnub.api.enums.PNPushType
import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult
Expand All @@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
import com.pubnub.kmp.PNFuture
import com.pubnub.kmp.onFailureHandler
import com.pubnub.kmp.onSuccessHandler
import com.pubnub.kmp.toNSData
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData

/**
* @see [PubNub.auditPushChannelProvisions]
Expand All @@ -29,15 +26,17 @@ class ListPushProvisionsImpl(
private val environment: PNPushEnvironment
) : ListPushProvisions {
override fun async(callback: Consumer<Result<PNPushListProvisionsResult>>) {
deviceId.toNSData()?.let { data: NSData ->
pubnub.listPushChannelsWithDeviceId(
deviceId = data,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it?.filterIsInstance<String>() ?: emptyList()) },
onFailure = callback.onFailureHandler()
)
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
pubnub.listPushChannelsWithDeviceId(
deviceId = deviceId,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler {
PNPushListProvisionsResult(
channels = it?.filterIsInstance<String>() ?: emptyList()
)
},
onFailure = callback.onFailureHandler()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push

import cocoapods.PubNubSwift.KMPPubNub
import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType
import com.pubnub.api.PubNubException
import com.pubnub.api.enums.PNPushEnvironment
import com.pubnub.api.enums.PNPushType
import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult
Expand All @@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
import com.pubnub.kmp.PNFuture
import com.pubnub.kmp.onFailureHandler
import com.pubnub.kmp.onSuccessReturnValue
import com.pubnub.kmp.toNSData
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData

/**
* @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken]
Expand All @@ -29,15 +26,13 @@ class RemoveAllPushChannelsForDeviceImpl(
private val environment: PNPushEnvironment
) : RemoveAllPushChannelsForDevice {
override fun async(callback: Consumer<Result<PNPushRemoveAllChannelsResult>>) {
deviceId.toNSData()?.let { data: NSData ->
pubnub.removeAllChannelsFromPushWithPushType(
pushType = pushType.toParamString(),
deviceId = data,
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()),
onFailure = callback.onFailureHandler()
)
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
pubnub.removeAllChannelsFromPushWithPushType(
pushType = pushType.toParamString(),
deviceId = deviceId,
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()),
onFailure = callback.onFailureHandler()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push

import cocoapods.PubNubSwift.KMPPubNub
import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels
import com.pubnub.api.PubNubException
import com.pubnub.api.enums.PNPushEnvironment
import com.pubnub.api.enums.PNPushType
import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult
Expand All @@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
import com.pubnub.kmp.PNFuture
import com.pubnub.kmp.onFailureHandler
import com.pubnub.kmp.onSuccessHandler
import com.pubnub.kmp.toNSData
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData

/**
* @see [PubNub.removePushNotificationsFromChannels]
Expand All @@ -30,16 +27,14 @@ class RemoveChannelsFromPushImpl(
private val environment: PNPushEnvironment,
) : RemoveChannelsFromPush {
override fun async(callback: Consumer<Result<PNPushRemoveChannelResult>>) {
deviceId.toNSData()?.let { data: NSData ->
pubnub.removeChannelsFromPushWithChannels(
channels = channels,
deviceId = data,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() },
onFailure = callback.onFailureHandler()
)
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
pubnub.removeChannelsFromPushWithChannels(
channels = channels,
deviceId = deviceId,
pushType = pushType.toParamString(),
topic = topic.orEmpty(),
environment = environment.toParamString(),
onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() },
onFailure = callback.onFailureHandler()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership
import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata
import com.pubnub.api.utils.PatchValue
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData
import platform.Foundation.NSString
import platform.Foundation.NSUTF8StringEncoding
import platform.Foundation.dataUsingEncoding

internal fun String.toNSData(): NSData? {
return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding)
}

@OptIn(ExperimentalForeignApi::class)
internal fun createPubNubHashedPage(from: PNPage?): KMPHashedPage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PubNubImplTest : BaseTest() {
fun getVersionAndTimeStamp() {
val version = PubNubImpl.SDK_VERSION
val timeStamp = PubNubImpl.timestamp()
assertEquals("10.4.3", version)
assertEquals("10.4.4", version)
assertTrue(timeStamp > 0)
}

Expand Down

0 comments on commit cf4bd64

Please sign in to comment.