Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMAC Push notification updates #283

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Sources/XMTPiOS/Push/XMTPPush.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import UIKit
import UserNotifications

public typealias NotificationSubscription = Notifications_V1_Subscription
public typealias NotificationSubscriptionHmacKey = Notifications_V1_Subscription.HmacKey

enum XMTPPushError: Error {
case noPushServer
}
Expand Down Expand Up @@ -76,6 +79,19 @@

_ = await client.subscribe(request: request)
}

public func subscribeWithMetadata(subscriptions: [NotificationSubscription]) async throws {
if pushServer == "" {
throw XMTPPushError.noPushServer
}

let request = Notifications_V1_SubscribeWithMetadataRequest.with { request in
request.installationID = installationID
request.subscriptions = subscriptions
}

_ = await client.subscribeWithMetadata(request: request)
}

public func unsubscribe(topics: [String]) async throws {
if pushServer == "" {
Expand Down Expand Up @@ -125,6 +141,10 @@
public func subscribe(topics _: [String]) async throws {
fatalError("XMTPPush not available")
}

public func subscribeWithMetadata(subscriptions _: [NotificationSubscription]) async throws {
zombieobject marked this conversation as resolved.
Show resolved Hide resolved
fatalError("XMTPPush not available")
}

public func unsubscribe(topics _: [String]) async throws {
fatalError("XMTPPush not available")
Expand Down
80 changes: 53 additions & 27 deletions Sources/XMTPiOS/Push/service.connect.swift
Original file line number Diff line number Diff line change
@@ -1,83 +1,109 @@
// Code generated by protoc-gen-connect-swift. DO NOT EDIT.
//
// Source: service.proto
// Source: notifications/v1/service.proto
//

import Connect
import Foundation
import SwiftProtobuf

public protocol Notifications_V1_NotificationsClientInterface {
public protocol Notifications_V1_NotificationsClientInterface: Sendable {

@discardableResult
func registerInstallation(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers, completion: @escaping (ResponseMessage<Notifications_V1_RegisterInstallationResponse>) -> Void) -> Connect.Cancelable
func `registerInstallation`(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers, completion: @escaping @Sendable (ResponseMessage<Notifications_V1_RegisterInstallationResponse>) -> Void) -> Connect.Cancelable
zombieobject marked this conversation as resolved.
Show resolved Hide resolved

func registerInstallation(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers) async -> ResponseMessage<Notifications_V1_RegisterInstallationResponse>
@available(iOS 13, *)
func `registerInstallation`(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers) async -> ResponseMessage<Notifications_V1_RegisterInstallationResponse>

@discardableResult
func deleteInstallation(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers, completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable
func `deleteInstallation`(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers, completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable

func deleteInstallation(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>
@available(iOS 13, *)
func `deleteInstallation`(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>

@discardableResult
func subscribe(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers, completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable
func `subscribe`(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers, completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable

func subscribe(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>
@available(iOS 13, *)
func `subscribe`(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>

@discardableResult
func unsubscribe(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers, completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable
func `subscribeWithMetadata`(request: Notifications_V1_SubscribeWithMetadataRequest, headers: Connect.Headers, completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable

@available(iOS 13, *)
func `subscribeWithMetadata`(request: Notifications_V1_SubscribeWithMetadataRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>

func unsubscribe(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>
@discardableResult
func `unsubscribe`(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers, completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable

@available(iOS 13, *)
func `unsubscribe`(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>
}

/// Concrete implementation of `Notifications_V1_NotificationsClientInterface`.
public final class Notifications_V1_NotificationsClient: Notifications_V1_NotificationsClientInterface {
public final class Notifications_V1_NotificationsClient: Notifications_V1_NotificationsClientInterface, Sendable {
private let client: Connect.ProtocolClientInterface

public init(client: Connect.ProtocolClientInterface) {
self.client = client
}

@discardableResult
public func registerInstallation(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers = [:], completion: @escaping (ResponseMessage<Notifications_V1_RegisterInstallationResponse>) -> Void) -> Connect.Cancelable {
return client.unary(path: "notifications.v1.Notifications/RegisterInstallation", request: request, headers: headers, completion: completion)
public func `registerInstallation`(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers = [:], completion: @escaping @Sendable (ResponseMessage<Notifications_V1_RegisterInstallationResponse>) -> Void) -> Connect.Cancelable {
return self.client.unary(path: "/notifications.v1.Notifications/RegisterInstallation", idempotencyLevel: .unknown, request: request, headers: headers, completion: completion)
zombieobject marked this conversation as resolved.
Show resolved Hide resolved
}

@available(iOS 13, *)
public func `registerInstallation`(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<Notifications_V1_RegisterInstallationResponse> {
return await self.client.unary(path: "/notifications.v1.Notifications/RegisterInstallation", idempotencyLevel: .unknown, request: request, headers: headers)
zombieobject marked this conversation as resolved.
Show resolved Hide resolved
}

@discardableResult
public func `deleteInstallation`(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers = [:], completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return self.client.unary(path: "/notifications.v1.Notifications/DeleteInstallation", idempotencyLevel: .unknown, request: request, headers: headers, completion: completion)
}

public func registerInstallation(request: Notifications_V1_RegisterInstallationRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<Notifications_V1_RegisterInstallationResponse> {
return await client.unary(path: "notifications.v1.Notifications/RegisterInstallation", request: request, headers: headers)
@available(iOS 13, *)
public func `deleteInstallation`(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await self.client.unary(path: "/notifications.v1.Notifications/DeleteInstallation", idempotencyLevel: .unknown, request: request, headers: headers)
}

@discardableResult
public func deleteInstallation(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers = [:], completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return client.unary(path: "notifications.v1.Notifications/DeleteInstallation", request: request, headers: headers, completion: completion)
public func `subscribe`(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers = [:], completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return self.client.unary(path: "/notifications.v1.Notifications/Subscribe", idempotencyLevel: .unknown, request: request, headers: headers, completion: completion)
}

public func deleteInstallation(request: Notifications_V1_DeleteInstallationRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await client.unary(path: "notifications.v1.Notifications/DeleteInstallation", request: request, headers: headers)
@available(iOS 13, *)
public func `subscribe`(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await self.client.unary(path: "/notifications.v1.Notifications/Subscribe", idempotencyLevel: .unknown, request: request, headers: headers)
}

@discardableResult
public func subscribe(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers = [:], completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return client.unary(path: "notifications.v1.Notifications/Subscribe", request: request, headers: headers, completion: completion)
public func `subscribeWithMetadata`(request: Notifications_V1_SubscribeWithMetadataRequest, headers: Connect.Headers = [:], completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return self.client.unary(path: "/notifications.v1.Notifications/SubscribeWithMetadata", idempotencyLevel: .unknown, request: request, headers: headers, completion: completion)
}

public func subscribe(request: Notifications_V1_SubscribeRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await client.unary(path: "notifications.v1.Notifications/Subscribe", request: request, headers: headers)
@available(iOS 13, *)
public func `subscribeWithMetadata`(request: Notifications_V1_SubscribeWithMetadataRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await self.client.unary(path: "/notifications.v1.Notifications/SubscribeWithMetadata", idempotencyLevel: .unknown, request: request, headers: headers)
}

@discardableResult
public func unsubscribe(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers = [:], completion: @escaping (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return client.unary(path: "notifications.v1.Notifications/Unsubscribe", request: request, headers: headers, completion: completion)
public func `unsubscribe`(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers = [:], completion: @escaping @Sendable (ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty>) -> Void) -> Connect.Cancelable {
return self.client.unary(path: "/notifications.v1.Notifications/Unsubscribe", idempotencyLevel: .unknown, request: request, headers: headers, completion: completion)
}

public func unsubscribe(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await client.unary(path: "notifications.v1.Notifications/Unsubscribe", request: request, headers: headers)
@available(iOS 13, *)
public func `unsubscribe`(request: Notifications_V1_UnsubscribeRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<SwiftProtobuf.Google_Protobuf_Empty> {
return await self.client.unary(path: "/notifications.v1.Notifications/Unsubscribe", idempotencyLevel: .unknown, request: request, headers: headers)
}

public enum Metadata {
public enum Methods {
public static let registerInstallation = Connect.MethodSpec(name: "RegisterInstallation", service: "notifications.v1.Notifications", type: .unary)
public static let deleteInstallation = Connect.MethodSpec(name: "DeleteInstallation", service: "notifications.v1.Notifications", type: .unary)
public static let subscribe = Connect.MethodSpec(name: "Subscribe", service: "notifications.v1.Notifications", type: .unary)
public static let subscribeWithMetadata = Connect.MethodSpec(name: "SubscribeWithMetadata", service: "notifications.v1.Notifications", type: .unary)
public static let unsubscribe = Connect.MethodSpec(name: "Unsubscribe", service: "notifications.v1.Notifications", type: .unary)
}
}
Expand Down
Loading
Loading