-
Notifications
You must be signed in to change notification settings - Fork 41
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
Deeplink not getting tracked. #127
base: main
Are you sure you want to change the base?
Changes from 6 commits
a17581f
2c0e90f
738fff0
2a8ed2d
3286a4e
eeac5d8
d102dc0
9a4f766
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,10 @@ import UIKit | |
import Foundation | ||
|
||
public class AnalyticsPlugin: NSObject, FlutterPlugin, NativeContextApi, FlutterStreamHandler, FlutterApplicationLifeCycleDelegate { | ||
private var pendingDeeplinkEventsQueue:[[String:String?]] = [] | ||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { | ||
_eventSink = events | ||
processPendingDeeplinkEventsQueue(); | ||
return nil | ||
} | ||
|
||
|
@@ -14,19 +16,25 @@ public class AnalyticsPlugin: NSObject, FlutterPlugin, NativeContextApi, Flutter | |
} | ||
|
||
var _eventSink:FlutterEventSink?; | ||
public func application(_ application: UIApplication, open url: URL, sourceApplication: String, annotation: Any) -> Bool { | ||
public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool{ | ||
let sourceApplication = options[.sourceApplication] as? String; | ||
if (_eventSink != nil) { | ||
_eventSink?(["url": url.absoluteString, "referringApplication": sourceApplication]) | ||
}else{ | ||
pendingDeeplinkEventsQueue.append(["url": url.absoluteString, "referringApplication": sourceApplication]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. "referrer". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. |
||
} | ||
return true | ||
return false | ||
} | ||
public func application(_ application: UIApplication, handleOpen url: URL) -> Bool { | ||
if (_eventSink != nil) { | ||
_eventSink?([url: url.absoluteString]) | ||
|
||
private func processPendingDeeplinkEventsQueue() -> Void{ | ||
if(_eventSink == nil){ | ||
return; | ||
} | ||
while(!pendingDeeplinkEventsQueue.isEmpty){ | ||
let eventData:[String:String?] = pendingDeeplinkEventsQueue.removeFirst(); | ||
_eventSink?(eventData); | ||
Rjaintwilio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return true | ||
} | ||
|
||
internal static var device = VendorSystem.current | ||
|
||
func getContext(collectDeviceId: Bool, completion: @escaping (Result<NativeContext, Error>) -> Void) { | ||
|
@@ -88,10 +96,12 @@ public class AnalyticsPlugin: NSObject, FlutterPlugin, NativeContextApi, Flutter | |
|
||
public static func register(with registrar: FlutterPluginRegistrar) { | ||
let messenger : FlutterBinaryMessenger = registrar.messenger() | ||
let api : NativeContextApi & NSObjectProtocol & AnalyticsPlugin = AnalyticsPlugin.init() | ||
let plugin = AnalyticsPlugin.init(); | ||
let api : NativeContextApi & NSObjectProtocol & AnalyticsPlugin = plugin | ||
NativeContextApiSetup.setUp(binaryMessenger: messenger, api: api) | ||
|
||
let channel:FlutterEventChannel = FlutterEventChannel(name: "analytics/deep_link_events", binaryMessenger: registrar.messenger()) | ||
channel.setStreamHandler(api) | ||
registrar.addApplicationDelegate(plugin) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this key should be "referrer" according to segment docs I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm it's "referrer" in analytics-kotlin.