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.
See the documentation for full documentation.
See the Migration Guide if upgrading from a previous version.
See the iOS Example App for more examples.
There are two ways to add this as a dependency using the Swift Package Manager:
- Using Xcode
- Manually via
Package.swift
- Open your Xcode project and select
File
->Add Packages...
- Search for
https://github.com/knocklabs/knock-swift.git
and then clickAdd 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.
If you are managing dependencies using the Package.swift
file, just add this to you dependencies array:
dependencies: [
.package(url: "https://github.com/knocklabs/knock-swift.git", .upToNextMajor(from: "1.2.4"))
]
Add the dependency to your Podfile
:
platform :ios, '16.0'
use_frameworks!
target 'MyApp' do
pod 'Knock', '~> 1.2.4'
end
- Add this line to your Cartfile:
github "knocklabs/knock-swift" ~> 1.1.0
As a last option, you could manually copy the files inside the Sources
folder to your project.
You can now start using the SDK:
import Knock
/*
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")
// Once you know the Knock UserId, sign the user into the shared Knock instance.
await Knock.shared.signIn(userId: "userid", userToken: nil)
Community contributions are welcome! If you'd like to contribute, please read our contribution guide.
This project is licensed under the MIT license.
See LICENSE for more information.