Skip to content

Commit 75afa3a

Browse files
authored
Update README.md
fix plugin examples
1 parent fafdff1 commit 75afa3a

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

README.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Method signature:
176176

177177
Example Usage:
178178
```swift
179-
analytics.add(plugin: UIKitScreenTracking(name: "ScreenTracking", analytics: analytics))
179+
analytics.add(plugin: UIKitScreenTracking(name: "ScreenTracking"))
180180
```
181181

182182
### find
@@ -235,9 +235,8 @@ class SomePlugin: Plugin {
235235
let name: String
236236
let analytics: Analytics
237237

238-
init(name: String, analytics: Analytics) {
238+
init(name: String) {
239239
self.name = name
240-
self.analytics = analytics
241240
}
242241

243242
override fun execute(event: BaseEvent): BaseEvent? {
@@ -260,9 +259,8 @@ class SomePlugin: EventPlugin {
260259
let name: String
261260
let analytics: Analytics
262261

263-
init(name: String, analytics: Analytics) {
262+
init(name: String) {
264263
self.name = name
265-
self.analytics = analytics
266264
}
267265

268266
func identify(event: IdentifyEvent) -> IdentifyEvent? {
@@ -280,34 +278,47 @@ class SomePlugin: EventPlugin {
280278
- `DestinationPlugin`
281279
A plugin interface most commonly used for device-mode destinations. This plugin contains an internal timeline that follows the same process as the analytics timeline,
282280
allowing you to modify/augment how events reach the particular destination.
283-
For example if you wanted to implement a device mode destination plugin for Amplitude
281+
For example if you wanted to implement a device mode destination plugin for AppsFlyer
284282
```swift
285-
class AmplitudePlugin: DestinationPlugin {
286-
let type: PluginType = .destination
287-
let name: String
288-
let analytics: Analytics
289-
let timeline: Timeline
290-
let amplitudeSDK: Amplitude
291-
292-
init(name: String, analytics: Analytics) {
293-
self.name = name
294-
self.analytics = analytics
295-
self.timeline = Timeline()
296-
297-
amplitudeSDK = Amplitude.instance()
298-
amplitudeSDK.initializeApiKey("API_KEY")
299-
}
300-
301-
func track(event: TrackEvent) -> TrackEvent? {
302-
amplitudeSDK.logEvent(event.name)
303-
return event
304-
}
283+
internal struct AppsFlyerSettings: Codable {
284+
let appsFlyerDevKey: String
285+
let appleAppID: String
286+
let trackAttributionData: Bool?
305287
}
306288

289+
@objc
290+
class AppsFlyerDestination: UIResponder, DestinationPlugin, UserActivities, RemoteNotifications {
291+
292+
let timeline: Timeline = Timeline()
293+
let type: PluginType = .destination
294+
let name: String
295+
var analytics: Analytics?
296+
297+
internal var settings: AppsFlyerSettings? = nil
298+
299+
required init(name: String) {
300+
self.name = name
301+
analytics?.track(name: "AppsFlyer Loaded")
302+
}
303+
304+
public func update(settings: Settings) {
305+
306+
guard let settings: AppsFlyerSettings = settings.integrationSettings(name: "AppsFlyer") else {return}
307+
self.settings = settings
308+
309+
310+
AppsFlyerLib.shared().appsFlyerDevKey = settings.appsFlyerDevKey
311+
AppsFlyerLib.shared().appleAppID = settings.appleAppID
312+
AppsFlyerLib.shared().isDebug = true
313+
AppsFlyerLib.shared().deepLinkDelegate = self
314+
315+
// additional update logic
316+
}
317+
307318
// ...
308319

309-
analytics.add(plugin: AmplitudePlugin(name: "Amplitude", analytics: analytics))
310-
analytics.track("Amplitude Event")
320+
analytics.add(plugin: AppsFlyerPlugin(name: "AppsFlyer"))
321+
analytics.track("AppsFlyer Event")
311322
```
312323

313324
### Advanced concepts

0 commit comments

Comments
 (0)