Skip to content

Commit

Permalink
Merge branch 'main' of github.com:knocklabs/knock-swift into matgar-i…
Browse files Browse the repository at this point in the history
…n-app-components

# Conflicts:
#	Sources/KnockEnvironment.swift
  • Loading branch information
matgar26 committed May 29, 2024
2 parents e30d11d + 1f4333a commit 7f7f9cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Knock.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Knock"
spec.version = "1.1.0"
spec.version = "1.1.1"
spec.summary = "An SDK to build in-app notifications experiences in Swift with Knock.."

spec.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion Sources/Knock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OSLog

// Knock client SDK.
public class Knock {
internal static let clientVersion = "1.1.0"
internal static let clientVersion = "1.1.1"

public static var shared: Knock = Knock()

Expand Down
4 changes: 2 additions & 2 deletions Sources/KnockAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ open class KnockAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat

open func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Task {
let channelId = await Knock.shared.environment.getPushChannelId()
let channelId = await Knock.shared.getPushChannelId()

do {
let _ = try await Knock.shared.channelModule.registerTokenForAPNS(channelId: channelId, token: Knock.convertTokenToString(token: deviceToken))
let _ = try await Knock.shared.registerTokenForAPNS(channelId: channelId, token: Knock.convertTokenToString(token: deviceToken))
} catch let error {
Knock.shared.log(type: .error, category: .pushNotification, message: "didRegisterForRemoteNotificationsWithDeviceToken", description: "Unable to register for push notification at this time", status: .fail, errorMessage: error.localizedDescription)
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/KnockEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal actor KnockEnvironment {
self.pushChannelId = newChannelId
}

public func getPushChannelId() -> String? {
func getPushChannelId() -> String? {
self.pushChannelId
}

Expand Down Expand Up @@ -129,43 +129,43 @@ internal actor KnockEnvironment {
}

public extension Knock {

func setUserInfo(userId: String?, userToken: String?) async {
await environment.setUserInfo(userId: userId, userToken: userToken)
}

func setUserInfo(userId: String?, userToken: String?, completion: @escaping () -> Void) {
Task {
await environment.setUserInfo(userId: userId, userToken: userToken)
completion()
}
}

/// Returns the userId that was set from the Knock.shared.signIn method.
func getUserId() async -> String? {
await environment.getUserId()
}

func getUserId(completion: @escaping (String?) -> Void) {
Task {
completion(await environment.getUserId())
}
}

func getDeviceToken() async -> String? {
await environment.getDeviceToken()
}

func getDeviceToken(completion: @escaping (String?) -> Void) {
Task {
completion(await environment.getDeviceToken())
}
}

func getPushChannelId() async -> String? {
await environment.getPushChannelId()
}

func getPushChannelId(completion: @escaping (String?) -> Void) {
Task {
completion(await environment.getPushChannelId())
Expand Down
4 changes: 2 additions & 2 deletions Sources/Modules/ChannelModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ public extension Knock {
- channelId: the id of the APNS channel
- token: the APNS device token as a `String`
*/
func registerTokenForAPNS(channelId: String, token: String) async throws -> ChannelData {
func registerTokenForAPNS(channelId: String?, token: String) async throws -> ChannelData {
return try await self.channelModule.registerTokenForAPNS(channelId: channelId, token: token)
}

func registerTokenForAPNS(channelId: String, token: String, completionHandler: @escaping ((Result<ChannelData, Error>) -> Void)) {
func registerTokenForAPNS(channelId: String?, token: String, completionHandler: @escaping ((Result<ChannelData, Error>) -> Void)) {
Task {
do {
let channelData = try await registerTokenForAPNS(channelId: channelId, token: token)
Expand Down

0 comments on commit 7f7f9cd

Please sign in to comment.