diff --git a/Examples/destination_plugins/AdjustDestination.swift b/Examples/destination_plugins/AdjustDestination.swift index 633ea550..fea21094 100644 --- a/Examples/destination_plugins/AdjustDestination.swift +++ b/Examples/destination_plugins/AdjustDestination.swift @@ -50,7 +50,7 @@ internal struct AdjustSettings: Codable { } @objc -public class AdjustDestination: NSObject, DestinationPlugin { +public class AdjustDestination: NSObject, DestinationPlugin, RemoteNotifications { public let timeline: Timeline = Timeline() public let type: PluginType = .destination public let name: String @@ -145,6 +145,16 @@ public class AdjustDestination: NSObject, DestinationPlugin { return event } + + public func reset() { + guard started == true else { return } + Adjust.resetSessionPartnerParameters() + } + + public func registeredForRemoteNotifications(deviceToken: Data) { + guard started == true else { return } + Adjust.setDeviceToken(deviceToken) + } } // MARK: - Adjust Delegate conformance diff --git a/Segment.xcodeproj/xcshareddata/xcschemes/SegmentExample.xcscheme b/Segment.xcodeproj/xcshareddata/xcschemes/SegmentExample.xcscheme deleted file mode 100644 index 1841f769..00000000 --- a/Segment.xcodeproj/xcshareddata/xcschemes/SegmentExample.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Sources/Segment/Analytics.swift b/Sources/Segment/Analytics.swift index b66758d8..9ba91578 100644 --- a/Sources/Segment/Analytics.swift +++ b/Sources/Segment/Analytics.swift @@ -85,11 +85,20 @@ extension Analytics { } public func flush() { - flushCurrentQueue() + apply { plugin in + if let p = plugin as? EventPlugin { + p.flush() + } + } } public func reset() { store.dispatch(action: UserInfo.ResetAction()) + apply { plugin in + if let p = plugin as? EventPlugin { + p.reset() + } + } } public func settings() -> Settings? { diff --git a/Sources/Segment/Plugins.swift b/Sources/Segment/Plugins.swift index 4f8271e3..a37ace32 100644 --- a/Sources/Segment/Plugins.swift +++ b/Sources/Segment/Plugins.swift @@ -41,6 +41,8 @@ public protocol EventPlugin: Plugin { func group(event: GroupEvent) -> GroupEvent? func alias(event: AliasEvent) -> AliasEvent? func screen(event: ScreenEvent) -> ScreenEvent? + func reset() + func flush() } public protocol DestinationPlugin: EventPlugin { diff --git a/Sources/Segment/Plugins/SegmentDestination.swift b/Sources/Segment/Plugins/SegmentDestination.swift index 923203c5..8de9b242 100644 --- a/Sources/Segment/Plugins/SegmentDestination.swift +++ b/Sources/Segment/Plugins/SegmentDestination.swift @@ -97,7 +97,7 @@ public class SegmentDestination: DestinationPlugin { } } - internal func flush() { + public func flush() { guard let storage = self.storage else { return } guard let analytics = self.analytics else { return } guard let httpClient = self.httpClient else { return } @@ -149,13 +149,3 @@ public class SegmentDestination: DestinationPlugin { } } } - -extension Analytics { - internal func flushCurrentQueue() { - apply { (plugin) in - if let destinationPlugin = plugin as? SegmentDestination { - destinationPlugin.flush() - } - } - } -} diff --git a/Sources/Segment/Timeline.swift b/Sources/Segment/Timeline.swift index ede49e6f..ad1b0738 100644 --- a/Sources/Segment/Timeline.swift +++ b/Sources/Segment/Timeline.swift @@ -189,6 +189,9 @@ extension EventPlugin { public func alias(event: AliasEvent) -> AliasEvent? { return event } + + public func flush() { } + public func reset() { } } // MARK: - Destination Timeline diff --git a/Sources/Segment/Version.swift b/Sources/Segment/Version.swift index 1d1210e2..8d4ea5b6 100644 --- a/Sources/Segment/Version.swift +++ b/Sources/Segment/Version.swift @@ -1,6 +1,6 @@ // // Version.swift -// Segment-Tests +// Segment // // Created by Brandon Sneed on 12/3/20. // @@ -8,4 +8,4 @@ // Referred to by Analytics.swift // BREAKING.FEATURE.FIX -internal let __segment_version = "5.0.0" +internal let __segment_version = "1.0.1"