-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e05e4de
commit 831639b
Showing
6 changed files
with
75 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// The PushNotificationResult structure | ||
public struct PushNotificationResult: Codable { | ||
public struct Response: Codable { | ||
public let successful: Bool | ||
public let pushedToNumberOfDevices: Int | ||
} | ||
public let sendPushNotification: Response | ||
} |
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
27 changes: 27 additions & 0 deletions
27
Sources/TibberSwift/Operations/PushNotificationOperation.swift
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,27 @@ | ||
import Foundation | ||
|
||
public extension GraphQLOperation where Input == EmptyInput, Output == PushNotificationResult { | ||
|
||
/// Sends a push notification to all logged-in devices of the user | ||
/// - Parameters: | ||
/// - title: Title of the notification | ||
/// - message: Message of the notification | ||
/// - Returns: ``GraphQLOperation`` for the notification | ||
static func pushNotification( | ||
title: String, | ||
message: String | ||
) throws -> Self { | ||
GraphQLOperation(input: EmptyInput(), | ||
operationString: """ | ||
mutation { | ||
sendPushNotification(input: { | ||
title: \"\(title)\", | ||
message: \"\(message)\" | ||
}){ | ||
successful | ||
pushedToNumberOfDevices | ||
} | ||
} | ||
""") | ||
} | ||
} |
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
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,8 @@ | ||
{ | ||
"data": { | ||
"sendPushNotification": { | ||
"successful": true, | ||
"pushedToNumberOfDevices": 1 | ||
} | ||
} | ||
} |