From d102dc00d8d22d63dd4110e5d30bbeacc898a585 Mon Sep 17 00:00:00 2001 From: Michael Grosse Huelsewiesche Date: Wed, 11 Dec 2024 16:38:53 -0500 Subject: [PATCH] Adjusting referring application to match documentation --- .../main/kotlin/com/segment/analytics/AnalyticsPlugin.kt | 6 +++--- packages/core/ios/Classes/AnalyticsPlugin.swift | 6 ++++-- packages/core/lib/state.g.dart | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt b/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt index d82f975..ef8d597 100644 --- a/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt +++ b/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt @@ -182,13 +182,13 @@ class AnalyticsPlugin : FlutterPlugin, NativeContextApi, EventChannel.StreamHand private fun createChangeReceiver(events: EventSink): BroadcastReceiver { return object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent) { - val referringApplication = intent.getStringExtra("referringApplication") + val referringApplication = intent.getStringExtra("referring_application") // NOTE: assuming intent.getAction() is Intent.ACTION_VIEW val dataString: String? = intent.dataString if (dataString == null) { events.error("UNAVAILABLE", "Link unavailable", null) } else { - val data = mapOf("url" to dataString, "referringApplication" to referringApplication) + val data = mapOf("url" to dataString, "referring_application" to referringApplication) events.success(data) } } @@ -234,7 +234,7 @@ class AnalyticsPlugin : FlutterPlugin, NativeContextApi, EventChannel.StreamHand if (this.context != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { binding.activity.intent.putExtra( - "referringApplication", + "referring_application", binding.activity.referrer.toString() ) } diff --git a/packages/core/ios/Classes/AnalyticsPlugin.swift b/packages/core/ios/Classes/AnalyticsPlugin.swift index 3b471ed..0dde117 100644 --- a/packages/core/ios/Classes/AnalyticsPlugin.swift +++ b/packages/core/ios/Classes/AnalyticsPlugin.swift @@ -19,10 +19,12 @@ public class AnalyticsPlugin: NSObject, FlutterPlugin, NativeContextApi, Flutter 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]) + _eventSink?(["url": url.absoluteString, "referring_application": sourceApplication]) }else{ - pendingDeeplinkEventsQueue.append(["url": url.absoluteString, "referringApplication": sourceApplication]); + pendingDeeplinkEventsQueue.append(["url": url.absoluteString, "referring_application": sourceApplication]); } + + return false } diff --git a/packages/core/lib/state.g.dart b/packages/core/lib/state.g.dart index bb848e3..0eb2f14 100644 --- a/packages/core/lib/state.g.dart +++ b/packages/core/lib/state.g.dart @@ -35,7 +35,7 @@ Map _$UserInfoToJson(UserInfo instance) { } DeepLinkData _$DeepLinkDataFromJson(Map json) => DeepLinkData( - json['referringApplication'] as String?, + json['referring_application'] as String?, json['url'] as String, ); @@ -48,7 +48,7 @@ Map _$DeepLinkDataToJson(DeepLinkData instance) { } } - writeNotNull('referringApplication', instance.referringApplication); + writeNotNull('referring_application', instance.referringApplication); val['url'] = instance.url; return val; }