GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improved service layer (#1) · feather-framework/feather-push@a88b1e1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Package.resolved
  • Package.swift
  • README.md
  • Sources/FeatherPush
    • Push.swift
    • Service+Push.swift
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Package.resolved‎

Copy file name to clipboardExpand all lines: Package.resolved
+2-2Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎Package.swift‎

Copy file name to clipboardExpand all lines: Package.swift
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import PackageDescription
44
let package = Package(
55
name: "feather-push",
66
platforms: [
7-
.macOS(.v10_15)
7+
.macOS(.v13),
8+
.iOS(.v16),
9+
.tvOS(.v16),
10+
.watchOS(.v9),
811
],
912
products: [
1013
.library(name: "FeatherPush", targets: ["FeatherPush"]),
1114
.library(name: "XCTFeatherPush", targets: ["XCTFeatherPush"]),
1215
],
1316
dependencies: [
14-
.package(url: "https://github.com/feather-framework/feather-service.git", .upToNextMinor(from: "0.1.0")),
17+
.package(url: "https://github.com/feather-framework/feather-service.git",
18+
.upToNextMinor(from: "0.2.0")
19+
),
1520
],
1621
targets: [
1722
.target(
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Feather Push
22

3-
An abstract push service for Feather CMS.
3+
An abstract push notification service for Feather CMS.
44

55
## Getting started
66

Collapse file

‎Sources/FeatherPush/Push.swift‎

Copy file name to clipboardExpand all lines: Sources/FeatherPush/Push.swift
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55
// Created by Tibor Bodecs on 2023. 01. 16..
66
//
77

8-
public enum Delivery: String {
8+
public enum Delivery: String, Sendable {
99
case normal
1010
case silent
1111
}
1212

1313
public enum Platform: Sendable {
14-
case ios
14+
case iOS
15+
case macOS
16+
case tvOS
17+
case watchOS
18+
case visionOS
19+
case safari
1520
case android
1621
case web
1722
case custom(String)
1823
}
1924

20-
public struct Recipient {
25+
public struct Recipient: Sendable {
2126
public let token: String
2227
public let platform: Platform
2328

@@ -30,7 +35,7 @@ public struct Recipient {
3035
}
3136
}
3237

33-
public struct Notification {
38+
public struct Notification: Sendable {
3439
public let title: String
3540
public let body: String
3641
public let userInfo: [String: String]
Collapse file

‎Sources/FeatherPush/Service+Push.swift‎

Copy file name to clipboard
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Service+Push.swift
3+
// FeatherPush
4+
//
5+
// Created by Tibor Bodecs on 20/11/2023.
6+
//
7+
8+
import FeatherService
9+
import Logging
10+
11+
public enum PushServiceID: ServiceID {
12+
13+
/// default push service identifier
14+
case `default`
15+
16+
/// custom push service identifier
17+
case custom(String)
18+
19+
public var rawId: String {
20+
switch self {
21+
case .default:
22+
return "push-id"
23+
case .custom(let value):
24+
return "\(value)-push-id"
25+
}
26+
}
27+
}
28+
29+
public extension ServiceRegistry {
30+
31+
/// add a new push service using a context
32+
func add(
33+
_ contextFactoryBuilder: @autoclosure @escaping () -> ServiceContext,
34+
id: PushServiceID = .default
35+
) async throws {
36+
try await add(.init { contextFactoryBuilder() }, id: id)
37+
}
38+
39+
/// returns a push service by a given id
40+
func push(
41+
_ id: PushServiceID = .default,
42+
logger: Logger? = nil
43+
) throws -> PushService {
44+
guard let push = try get(id, logger: logger) as? PushService else {
45+
fatalError("Push service not found, use `add` to register.")
46+
}
47+
return push
48+
}
49+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.