Skip to content
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
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
build-and-test:
name: Build and Test
runs-on: macos-14

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Select Xcode version
run: sudo xcode-select -switch /Applications/Xcode_15.2.app

- name: Show versions
run: |
xcodebuild -version
swift --version

- name: Resolve dependencies
run: swift package resolve

- name: Build for iOS Simulator
run: |
xcodebuild build-for-testing \
-scheme Knock \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
ONLY_ACTIVE_ARCH=NO

- name: Run tests
run: |
xcodebuild test-without-building \
-scheme Knock \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \
-enableCodeCoverage YES
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
LocalHelp.md
LocalHelp.md
*.xcodeproj
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.2.5"
spec.version = "1.2.6"
spec.summary = "An SDK to build in-app notifications experiences in Swift with Knock."

spec.description = <<-DESC
Expand Down
583 changes: 0 additions & 583 deletions Knock.xcodeproj/project.pbxproj

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

66 changes: 0 additions & 66 deletions Knock.xcodeproj/xcshareddata/xcschemes/Knock 1.xcscheme

This file was deleted.

79 changes: 0 additions & 79 deletions Knock.xcodeproj/xcshareddata/xcschemes/Knock.xcscheme

This file was deleted.

21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Official Knock iOS SDK

[![GitHub Release](https://img.shields.io/github/v/release/knocklabs/knock-swift?style=flat)](https://github.com/knocklabs/knock-swift/releases/latest)
Expand All @@ -10,8 +9,6 @@
![min ios version is 16](https://img.shields.io/badge/min%20iOS%20version-16-blue)
[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/knocklabs/ios-example-app/blob/main/LICENSE)



---

Knock is a flexible, reliable notifications infrastructure that's built to scale with you. Use our iOS SDK to engage users with in-app feeds, setup push notifications, and manage notification preferences.
Expand All @@ -34,7 +31,7 @@ See the [iOS Example App](https://github.com/knocklabs/ios-example-app) for more

### Swift Package Manager

There are two ways to add this as a dependency using the Swift Package Manager:
There are two ways to add this as a dependency using the Swift Package Manager:

1. Using Xcode
2. Manually via `Package.swift`
Expand All @@ -46,17 +43,17 @@ There are two ways to add this as a dependency using the Swift Package Manager:
<img width="422" alt="Screenshot 2023-06-27 at 19 41 32" src="https://github.com/knocklabs/knock-swift/assets/952873/31bb67de-5272-445a-a5c4-5df3bcfa3c8b">

2. Search for `https://github.com/knocklabs/knock-swift.git` and then click `Add Package`
*Note: We recommend that you set the Dependency Rule to Up to Next Major Version. While we encourage you to keep your app up to date with the latest SDK, major versions can include breaking changes or new features that require your attention.*
_Note: We recommend that you set the Dependency Rule to Up to Next Major Version. While we encourage you to keep your app up to date with the latest SDK, major versions can include breaking changes or new features that require your attention._

<img width="900" alt="Screenshot 2023-06-27 at 19 42 09" src="https://github.com/knocklabs/knock-swift/assets/952873/d947cc7f-8da6-4814-aa75-3e41ffe72ff4">

#### Manually via `Package.swift`

If you are managing dependencies using the `Package.swift` file, just add this to you dependencies array:

``` swift
```swift
dependencies: [
.package(url: "https://github.com/knocklabs/knock-swift.git", .upToNextMajor(from: "1.2.5"))
.package(url: "https://github.com/knocklabs/knock-swift.git", .upToNextMajor(from: "1.2.6"))
]
```

Expand All @@ -69,7 +66,7 @@ platform :ios, '16.0'
use_frameworks!

target 'MyApp' do
pod 'Knock', '~> 1.2.5'
pod 'Knock', '~> 1.2.6'
end
```

Expand All @@ -89,12 +86,12 @@ As a last option, you could manually copy the files inside the `Sources` folder

You can now start using the SDK:

``` swift
```swift
import Knock

/*
Setup the shared Knock instance as soon as you can.
Note: pushChannelId is required if you want to use our KnockAppDelegate helper.
/*
Setup the shared Knock instance as soon as you can.
Note: pushChannelId is required if you want to use our KnockAppDelegate helper.
Otherwise, this field is optional.
*/
try? Knock.shared.setup(publishableKey: "your-pk", pushChannelId: "apns-push-channel-id")
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.2.5"
internal static let clientVersion = "1.2.6"

public static var shared: Knock = Knock()

Expand Down
21 changes: 13 additions & 8 deletions Sources/Models/ChannelData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@
//

import Foundation
import AnyCodable

public extension Knock {
struct ChannelData: Codable {
public let channel_id: String
public let data: ChannelDataData?
public let data: [String: AnyCodable]?

public init(channel_id: String, data: [String: AnyCodable]?) {
self.channel_id = channel_id
self.data = data
}
}

struct ChannelDataData: Codable {
public let tokens: [String]?
public let devices: [Device]?
}

struct Device: Codable {
struct Device: Codable, Equatable {
public let token: String
public let locale: String?
public let timezone: String?

public init(token: String, locale: String?, timezone: String?) {
self.token = token
self.locale = locale
self.timezone = timezone
}
}
}
Loading