Skip to content

Commit

Permalink
v1.0.0 (#2)
Browse files Browse the repository at this point in the history
* initialized base package
  • Loading branch information
timokoethe authored May 23, 2024
1 parent 4ac0187 commit 8696c96
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 32 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build

on:
push:
branches:
- main
- development

jobs:
build:
name: Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: '5.9'
- name: Build
run: swift build
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test

on:
push:
branches:
- main
- development

jobs:
build:
name: Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: '5.9'
- name: Run Tests
run: swift test -v
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import PackageDescription

let package = Package(
name: "NotificationManager",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "NotificationManager",
targets: ["NotificationManager"]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "NotificationManager"),
.testTarget(
Expand Down
107 changes: 103 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# NotificationManager
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org/license/mit)
[![Build](https://github.com/timokoethe/NotificationManager/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/timokoethe/NotificationManager/actions/workflows/build.yml)
[![Test](https://github.com/timokoethe/NotificationManager/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/timokoethe/NotificationManager/actions/workflows/test.yml)

NotificationManager is a Swift Package to make your code easier for managing local notifications.
This package is supposed to make it possible to manage notifications in a highly intuitive way.
It shall also appear as minimalistic as possible.

## Integration
## Requirements
- Xcode 15.0+
- macOS 10.15+
- iOS 13.0+
- watchOS 6.0+


## Installation
1. Copy the resource url:
```
https://github.com/timokoethe/NotificationManager.git
Expand All @@ -14,6 +23,96 @@ https://github.com/timokoethe/NotificationManager.git
3. Navigate to _File_ / _Add Package Dependency_.
4. Paste the resource url at the top right corner in _Search or Enter Package URL_.
5. Choose the right target under _Add to project_.
6. To complete hit _Add Package_
7. Add ```import NotificationManager```to the top of the files in which you want to use it.
<br>
6. To complete hit _Add Package_.

## Setup
1. Importing the Framework <br>
In any Swift file where you want to use NotificationManager, add the following import statement:
```import NotificationManager```

2. Request notification authorization <br>
Before your app can send notifications, you need to request permission from the user. This is typically done when the app first launches. Add the following code to your App struct or the place wherever you want to ask the user to permit:
```
import SwiftUI
import UserNotifications
import NotificationManager
@main
struct YourApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onAppear {
requestNotificationAuthorization()
}
}
}
}
```

## Usage
- Scheduling a Notification <br>
Once you have authorization, you can schedule notifications. Here's an example of how to schedule a notification that should arrive after 10 seconds using NotificationManager by pushing a button:

```
import SwiftUI
import NotificationManager
struct ContentView: View {
var body: some View {
VStack {
Button("Schedule") {
NotificationManager.scheduleNotification(id: UUID().uuidString, title: "Title", body: "Body", triggerDate: Date()+10)
}
}
}
}
```

- Getting pending notifications
Once you have scheduled one or more notifications you can get all pending:
```
import SwiftUI
import NotificationManager
struct ContentView: View {
@State private var notifications = [UNNotificationRequest]()
var body: some View {
VStack {
Button("Get") {
Task {
notifications = await NotificationManager.getPendingNotificationRequests()
}
}
}
}
}
```

- Removing all pending notifications <br>
After scheduling several notifications you can remove them easily:
```
import SwiftUI
import NotificationManager
struct ContentView: View {
var body: some View {
VStack {
Button("Remove") {
NotificationManager.removeAllPendingNotificationRequests()
}
}
}
}
```

## Contributing
We welcome contributions from the community to help improve NotificationManager. If you encounter any bugs, have feature requests, or would like to contribute code, please feel free to open an issue or submit a pull request on our GitHub repository.

## Support
If you have any questions, feedback, or need assistance with NotificationManager, please don't hesitate to contact us. We're here to help!

## License
NotificationManager is released under the [MIT License](https://opensource.org/license/mit).

Feel free to adjust and expand upon this template to better suit your project's needs!
Loading

0 comments on commit 8696c96

Please sign in to comment.