Skip to content

Commit cf4bd64

Browse files
authored
Apple platform fixes (#337)
* Fix issue with passing the device token * Update PubNub Swift SDK dependency * PubNub SDK v10.4.4 release
1 parent c30e2f0 commit cf4bd64

File tree

11 files changed

+57
-70
lines changed

11 files changed

+57
-70
lines changed

.pubnub.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: kotlin
2-
version: 10.4.3
2+
version: 10.4.4
33
schema: 1
44
scm: github.com/pubnub/kotlin
55
files:
6-
- build/libs/pubnub-kotlin-10.4.3-all.jar
6+
- build/libs/pubnub-kotlin-10.4.4-all.jar
77
sdks:
88
-
99
type: library
@@ -23,8 +23,8 @@ sdks:
2323
-
2424
distribution-type: library
2525
distribution-repository: maven
26-
package-name: pubnub-kotlin-10.4.3
27-
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.4.3/pubnub-kotlin-10.4.3.jar
26+
package-name: pubnub-kotlin-10.4.4
27+
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.4.4/pubnub-kotlin-10.4.4.jar
2828
supported-platforms:
2929
supported-operating-systems:
3030
Android:
@@ -121,6 +121,11 @@ sdks:
121121
license-url: https://www.apache.org/licenses/LICENSE-2.0.txt
122122
is-required: Required
123123
changelog:
124+
- date: 2025-03-07
125+
version: v10.4.4
126+
changes:
127+
- type: bug
128+
text: "Internal fixes."
124129
- date: 2025-02-28
125130
version: v10.4.3
126131
changes:

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v10.4.4
2+
March 07 2025
3+
4+
#### Fixed
5+
- Internal fixes.
6+
17
## v10.4.3
28
February 28 2025
39

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
2020
<dependency>
2121
<groupId>com.pubnub</groupId>
2222
<artifactId>pubnub-kotlin</artifactId>
23-
<version>10.4.3</version>
23+
<version>10.4.4</version>
2424
</dependency>
2525
```
2626

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RELEASE_SIGNING_ENABLED=true
1818
SONATYPE_HOST=DEFAULT
1919
SONATYPE_AUTOMATIC_RELEASE=false
2020
GROUP=com.pubnub
21-
VERSION_NAME=10.4.3
21+
VERSION_NAME=10.4.4
2222
POM_PACKAGING=jar
2323

2424
POM_NAME=PubNub SDK

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dokka = "1.9.20"
1313
kotlinx_datetime = "0.6.1"
1414
kotlinx_coroutines = "1.9.0"
1515
pubnub_js = "8.6.0"
16-
pubnub_swift = "8.3.0"
16+
pubnub_swift = "9.0.0"
1717

1818
[libraries]
1919
retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit2" }

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt

+9-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push
22

33
import cocoapods.PubNubSwift.KMPPubNub
44
import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels
5-
import com.pubnub.api.PubNubException
65
import com.pubnub.api.enums.PNPushEnvironment
76
import com.pubnub.api.enums.PNPushType
87
import com.pubnub.api.models.consumer.push.PNPushAddChannelResult
@@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
1110
import com.pubnub.kmp.PNFuture
1211
import com.pubnub.kmp.onFailureHandler
1312
import com.pubnub.kmp.onSuccessHandler
14-
import com.pubnub.kmp.toNSData
1513
import kotlinx.cinterop.ExperimentalForeignApi
16-
import platform.Foundation.NSData
1714

1815
/**
1916
* @see [PubNub.addPushNotificationsOnChannels]
@@ -30,16 +27,14 @@ class AddChannelsToPushImpl(
3027
private val environment: PNPushEnvironment
3128
) : AddChannelsToPush {
3229
override fun async(callback: Consumer<Result<PNPushAddChannelResult>>) {
33-
deviceId.toNSData()?.let { data: NSData ->
34-
pubnub.addChannelsToPushNotificationsWithChannels(
35-
channels = channels,
36-
deviceId = data,
37-
pushType = pushType.toParamString(),
38-
topic = topic.orEmpty(),
39-
environment = environment.toParamString(),
40-
onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() },
41-
onFailure = callback.onFailureHandler()
42-
)
43-
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
30+
pubnub.addChannelsToPushNotificationsWithChannels(
31+
channels = channels,
32+
deviceId = deviceId,
33+
pushType = pushType.toParamString(),
34+
topic = topic.orEmpty(),
35+
environment = environment.toParamString(),
36+
onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() },
37+
onFailure = callback.onFailureHandler()
38+
)
4439
}
4540
}

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push
22

33
import cocoapods.PubNubSwift.KMPPubNub
44
import cocoapods.PubNubSwift.listPushChannelsWithDeviceId
5-
import com.pubnub.api.PubNubException
65
import com.pubnub.api.enums.PNPushEnvironment
76
import com.pubnub.api.enums.PNPushType
87
import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult
@@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
1110
import com.pubnub.kmp.PNFuture
1211
import com.pubnub.kmp.onFailureHandler
1312
import com.pubnub.kmp.onSuccessHandler
14-
import com.pubnub.kmp.toNSData
1513
import kotlinx.cinterop.ExperimentalForeignApi
16-
import platform.Foundation.NSData
1714

1815
/**
1916
* @see [PubNub.auditPushChannelProvisions]
@@ -29,15 +26,17 @@ class ListPushProvisionsImpl(
2926
private val environment: PNPushEnvironment
3027
) : ListPushProvisions {
3128
override fun async(callback: Consumer<Result<PNPushListProvisionsResult>>) {
32-
deviceId.toNSData()?.let { data: NSData ->
33-
pubnub.listPushChannelsWithDeviceId(
34-
deviceId = data,
35-
pushType = pushType.toParamString(),
36-
topic = topic.orEmpty(),
37-
environment = environment.toParamString(),
38-
onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it?.filterIsInstance<String>() ?: emptyList()) },
39-
onFailure = callback.onFailureHandler()
40-
)
41-
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
29+
pubnub.listPushChannelsWithDeviceId(
30+
deviceId = deviceId,
31+
pushType = pushType.toParamString(),
32+
topic = topic.orEmpty(),
33+
environment = environment.toParamString(),
34+
onSuccess = callback.onSuccessHandler {
35+
PNPushListProvisionsResult(
36+
channels = it?.filterIsInstance<String>() ?: emptyList()
37+
)
38+
},
39+
onFailure = callback.onFailureHandler()
40+
)
4241
}
4342
}

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt

+8-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push
22

33
import cocoapods.PubNubSwift.KMPPubNub
44
import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType
5-
import com.pubnub.api.PubNubException
65
import com.pubnub.api.enums.PNPushEnvironment
76
import com.pubnub.api.enums.PNPushType
87
import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult
@@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
1110
import com.pubnub.kmp.PNFuture
1211
import com.pubnub.kmp.onFailureHandler
1312
import com.pubnub.kmp.onSuccessReturnValue
14-
import com.pubnub.kmp.toNSData
1513
import kotlinx.cinterop.ExperimentalForeignApi
16-
import platform.Foundation.NSData
1714

1815
/**
1916
* @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken]
@@ -29,15 +26,13 @@ class RemoveAllPushChannelsForDeviceImpl(
2926
private val environment: PNPushEnvironment
3027
) : RemoveAllPushChannelsForDevice {
3128
override fun async(callback: Consumer<Result<PNPushRemoveAllChannelsResult>>) {
32-
deviceId.toNSData()?.let { data: NSData ->
33-
pubnub.removeAllChannelsFromPushWithPushType(
34-
pushType = pushType.toParamString(),
35-
deviceId = data,
36-
topic = topic.orEmpty(),
37-
environment = environment.toParamString(),
38-
onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()),
39-
onFailure = callback.onFailureHandler()
40-
)
41-
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
29+
pubnub.removeAllChannelsFromPushWithPushType(
30+
pushType = pushType.toParamString(),
31+
deviceId = deviceId,
32+
topic = topic.orEmpty(),
33+
environment = environment.toParamString(),
34+
onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()),
35+
onFailure = callback.onFailureHandler()
36+
)
4237
}
4338
}

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt

+9-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push
22

33
import cocoapods.PubNubSwift.KMPPubNub
44
import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels
5-
import com.pubnub.api.PubNubException
65
import com.pubnub.api.enums.PNPushEnvironment
76
import com.pubnub.api.enums.PNPushType
87
import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult
@@ -11,9 +10,7 @@ import com.pubnub.api.v2.callbacks.Result
1110
import com.pubnub.kmp.PNFuture
1211
import com.pubnub.kmp.onFailureHandler
1312
import com.pubnub.kmp.onSuccessHandler
14-
import com.pubnub.kmp.toNSData
1513
import kotlinx.cinterop.ExperimentalForeignApi
16-
import platform.Foundation.NSData
1714

1815
/**
1916
* @see [PubNub.removePushNotificationsFromChannels]
@@ -30,16 +27,14 @@ class RemoveChannelsFromPushImpl(
3027
private val environment: PNPushEnvironment,
3128
) : RemoveChannelsFromPush {
3229
override fun async(callback: Consumer<Result<PNPushRemoveChannelResult>>) {
33-
deviceId.toNSData()?.let { data: NSData ->
34-
pubnub.removeChannelsFromPushWithChannels(
35-
channels = channels,
36-
deviceId = data,
37-
pushType = pushType.toParamString(),
38-
topic = topic.orEmpty(),
39-
environment = environment.toParamString(),
40-
onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() },
41-
onFailure = callback.onFailureHandler()
42-
)
43-
} ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId")))
30+
pubnub.removeChannelsFromPushWithChannels(
31+
channels = channels,
32+
deviceId = deviceId,
33+
pushType = pushType.toParamString(),
34+
topic = topic.orEmpty(),
35+
environment = environment.toParamString(),
36+
onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() },
37+
onFailure = callback.onFailureHandler()
38+
)
4439
}
4540
}

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/kmp/converters.kt

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership
1414
import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata
1515
import com.pubnub.api.utils.PatchValue
1616
import kotlinx.cinterop.ExperimentalForeignApi
17-
import platform.Foundation.NSData
18-
import platform.Foundation.NSString
19-
import platform.Foundation.NSUTF8StringEncoding
20-
import platform.Foundation.dataUsingEncoding
21-
22-
internal fun String.toNSData(): NSData? {
23-
return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding)
24-
}
2517

2618
@OptIn(ExperimentalForeignApi::class)
2719
internal fun createPubNubHashedPage(from: PNPage?): KMPHashedPage {

pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PubNubImplTest : BaseTest() {
5656
fun getVersionAndTimeStamp() {
5757
val version = PubNubImpl.SDK_VERSION
5858
val timeStamp = PubNubImpl.timestamp()
59-
assertEquals("10.4.3", version)
59+
assertEquals("10.4.4", version)
6060
assertTrue(timeStamp > 0)
6161
}
6262

0 commit comments

Comments
 (0)