Skip to content

Added additional method for declining remote notifications #225

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

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all 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
9 changes: 9 additions & 0 deletions Sources/Segment/Plugins/Platforms/iOS/iOSDelegation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ import UIKit
// MARK: - Remote Notifications

public protocol RemoteNotifications: Plugin {
func declinedRemoteNotifications()
func registeredForRemoteNotifications(deviceToken: Data)
func failedToRegisterForRemoteNotification(error: Error?)
func receivedRemoteNotification(userInfo: [AnyHashable: Any])
func handleAction(identifier: String, userInfo: [String: Any])
}

extension RemoteNotifications {
public func declinedRemoteNotifications() {}
public func registeredForRemoteNotifications(deviceToken: Data) {}
public func failedToRegisterForRemoteNotification(error: Error?) {}
public func receivedRemoteNotification(userInfo: [AnyHashable: Any]) {}
public func handleAction(identifier: String, userInfo: [String: Any]) {}
}

extension Analytics {
public func declinedRemoteNotifications() {
apply { plugin in
if let p = plugin as? RemoteNotifications {
p.declinedRemoteNotifications()
}
}
}
public func registeredForRemoteNotifications(deviceToken: Data) {
setDeviceToken(deviceToken.hexString)

Expand Down