-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initialization Strategy and Unregistering from Push (#2) * Starting on initial refactor * initial refactor * Implemented shared Knock instance * added device unregistration functionality * Added more safety around the userId checks * Cleanup * Make KnockError a LocalizedError * Updated KnockOptions init * updates * Matgar26 kno 5091 modules (#3) * Starting on initial refactor * initial refactor * Implemented shared Knock instance * added device unregistration functionality * Added more safety around the userId checks * Cleanup * Make KnockError a LocalizedError * Updated KnockOptions init * updates * Introduce Modules and Services for independent responsibilities * Authentication * fixes * set version on api base path * Fixes * fix * implementation fix * Updated logging * Working on tests * created shared Knock instance * refactored logging * refactored logging * Adding more tests * [KNO-5189]: Token management and doc updates (#4) * Documentation updates and refactor KnockEnvironment to be and actor to avoid race conditions * adding token handling * readme updates * Added migration guide * Small fixes * Added additional props to FeedItem * Cleanup * final cleanup * spelling fix * Cleanup based on PR feedback
- Loading branch information
Showing
52 changed files
with
2,553 additions
and
962 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,103 @@ | ||
# ``Knock`` | ||
# Offical Knock iOS SDK | ||
|
||
<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@--> | ||
[![GitHub Release](https://img.shields.io/github/v/release/knocklabs/knock-swift?style=flat)](https://github.com/knocklabs/knock-swift/releases/latest) | ||
[![CocoaPods](https://img.shields.io/cocoapods/v/Knock.svg?style=flat)](https://cocoapods.org/) | ||
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) | ||
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/) | ||
|
||
## Overview | ||
![min swift version is 5.3](https://img.shields.io/badge/min%20Swift%20version-5.3-orange) | ||
![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) | ||
|
||
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@--> | ||
|
||
## Topics | ||
~ | ||
|
||
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@--> | ||
--- | ||
|
||
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@--> | ||
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. | ||
|
||
--- | ||
|
||
## Documentation | ||
|
||
See the [documentation](https://docs.knock.app/notification-feeds/bring-your-own-ui) for usage examples. | ||
|
||
## Installation | ||
|
||
### 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` | ||
|
||
#### Using Xcode | ||
|
||
1. Open your Xcode project and select `File` -> `Add Packages...` | ||
|
||
<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.* | ||
|
||
<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 | ||
dependencies: [ | ||
.package(url: "https://github.com/knocklabs/knock-swift.git", .upToNextMajor(from: "1.0.0")) | ||
] | ||
``` | ||
|
||
### Cocoapods | ||
|
||
Add the dependency to your `Podfile`: | ||
|
||
``` | ||
platform :ios, '16.0' | ||
use_frameworks! | ||
target 'MyApp' do | ||
pod 'Knock', '~> 0.2.0' | ||
end | ||
``` | ||
|
||
### Carthage | ||
|
||
1. Add this line to your Cartfile: | ||
|
||
``` | ||
github "knocklabs/knock-swift" ~> 0.2.0 | ||
``` | ||
|
||
### Manually | ||
|
||
As a last option, you could manually copy the files inside the `Sources` folder to your project. | ||
|
||
## Import and start using the SDK | ||
|
||
You can now start using the SDK: | ||
|
||
``` swift | ||
import Knock | ||
|
||
// Setup the shared Knock instance as soon as you can. | ||
try? Knock.shared.setup(publishableKey: "your-pk", pushChannelId: "user-id") | ||
|
||
// Once you know the Knock UserId, sign the user into the shared Knock instance. | ||
await Knock.shared.signIn(userId: "userid", userToken: nil) | ||
|
||
``` | ||
|
||
## How to Contribute | ||
|
||
Community contributions are welcome! If you'd like to contribute, please read our [contribution guide](CONTRIBUTING.md). | ||
|
||
## License | ||
|
||
This project is licensed under the MIT license. | ||
|
||
See [LICENSE](LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = "Knock" | ||
spec.version = "0.2.1" | ||
spec.version = "1.0.0" | ||
spec.summary = "An SDK to build in-app notifications experiences in Swift with Knock.." | ||
|
||
spec.description = <<-DESC | ||
|
@@ -16,6 +16,6 @@ Pod::Spec.new do |spec| | |
spec.author = { "Knock" => "[email protected]" } | ||
spec.source = { :git => "https://github.com/knocklabs/knock-swift.git", :tag => "#{spec.version}" } | ||
spec.ios.deployment_target = '16.0' | ||
spec.swift_version = '5.0' | ||
spec.swift_version = '5.3' | ||
spec.source_files = "Sources/**/*" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Migration Guide | ||
|
||
## Upgrading to Version 1.0.0 | ||
|
||
Version 1.0.0 of our Swift SDK introduces significant improvements and modernizations, including the adoption of Async/Await patterns for more concise and readable asynchronous code. While maintaining backward compatibility with completion handlers for all our APIs, we've also introduced several enhancements to optimize and streamline the SDK's usability. | ||
|
||
### Key Enhancements: | ||
|
||
- **Refined Initialization Process**: We've redesigned the initialization process for the Knock instance, dividing it into two distinct phases. This change offers greater flexibility in integrating our SDK into your projects. | ||
|
||
#### Previous Initialization Approach: | ||
```swift | ||
let client = try! Knock(publishableKey: publishableKey, "your-pk": "user-id", hostname: "hostname") | ||
``` | ||
|
||
#### New in Version 1.0.0: | ||
```swift | ||
// Step 1: Early initialization. Ideal place: AppDelegate. | ||
try? Knock.shared.setup(publishableKey: "your-pk", pushChannelId: "apns-channel-id", options: nil) | ||
|
||
// Step 2: Sign in the user. Ideal timing: as soon as you have the userId. | ||
await Knock.shared.signIn(userId: "userid", userToken: nil) | ||
``` | ||
|
||
- **KnockAppDelegate for Simplified Notification Management**: The introduction of `KnockAppDelegate` allows for effortless integration of push notification handling and token management, reducing boilerplate code and simplifying implementation. | ||
|
||
- **Enhanced User Session Management**: New functionalities to sign users out and unregister device tokens have been added, providing more control over user sessions and device management. | ||
|
||
- **Centralized Access with Shared Instance**: The SDK now utilizes a shared instance for the Knock client, facilitating easier access and interaction within your app's codebase. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.