Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build/
**/Package.resolved

**/*/Flutter/ephemeral
.osgrep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import java.util.Currency
import com.facebook.LoggingBehavior
import com.facebook.applinks.AppLinkData
import android.net.Uri

/** FacebookAppEventsPlugin */
class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler {
Expand Down Expand Up @@ -61,6 +63,9 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler {
"getAnonymousId" -> handleGetAnonymousId(call, result)
"logPurchase" -> handlePurchased(call, result)
"setAdvertiserTracking" -> handleSetAdvertiserTracking(call, result)
"fetchDeferredAppLink" -> handleFetchDeferredAppLink(call, result)
"setDebugEnabled" -> handleSetDebugEnabled(call, result)
"recordAndUpdateAEMEvent" -> result.success(null) // AEM is iOS-only, no-op on Android

else -> result.notImplemented()
}
Expand Down Expand Up @@ -138,6 +143,24 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler {
result.success(null)
}

private fun handleSetDebugEnabled(call: MethodCall, result: Result) {
val enabled = call.arguments as? Boolean ?: false

FacebookSdk.setIsDebugEnabled(enabled)

if (enabled) {
FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS)
FacebookSdk.addLoggingBehavior(LoggingBehavior.REQUESTS)
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_RAW_RESPONSES)
} else {
FacebookSdk.removeLoggingBehavior(LoggingBehavior.APP_EVENTS)
FacebookSdk.removeLoggingBehavior(LoggingBehavior.REQUESTS)
FacebookSdk.removeLoggingBehavior(LoggingBehavior.INCLUDE_RAW_RESPONSES)
}

result.success(null)
}

private fun handleLogEvent(call: MethodCall, result: Result) {
val eventName = call.argument<String>("name")
if (eventName == null) {
Expand Down Expand Up @@ -251,4 +274,57 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler {
appEventsLogger.logPurchase(amount, currency, parameterBundle)
result.success(null)
}

private fun handleFetchDeferredAppLink(call: MethodCall, result: Result) {
val context = application
if (context == null) {
result.success(null)
return
}

AppLinkData.fetchDeferredAppLinkData(context) { appLinkData ->
if (appLinkData == null) {
result.success(null)
return@fetchDeferredAppLinkData
}

val targetUri = appLinkData.targetUri
if (targetUri == null) {
result.success(null)
return@fetchDeferredAppLinkData
}

val data = mutableMapOf<String, Any>(
"targetUrl" to targetUri.toString()
)

// Extract query parameters from the target URI
val queryParams = mutableMapOf<String, String>()
targetUri.queryParameterNames?.forEach { paramName ->
targetUri.getQueryParameter(paramName)?.let { paramValue ->
queryParams[paramName] = paramValue

// Extract known Facebook parameters
if (paramName == "fb_click_time_utc") {
data["clickTimestamp"] = paramValue
}
}
}
if (queryParams.isNotEmpty()) {
data["queryParameters"] = queryParams
}

// Add promotion code if available
appLinkData.promotionCode?.let { promoCode ->
data["promotionCode"] = promoCode
}

// Add referrer data if available
appLinkData.ref?.let { ref ->
data["ref"] = ref
}

result.success(data)
}
}
}
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.1" apply false
id "com.android.application" version "8.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
# platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- facebook_app_events (0.20.0):
- facebook_app_events (0.24.0):
- FBSDKCoreKit (~> 18.0)
- Flutter
- FBAEMKit (18.0.0):
Expand Down Expand Up @@ -27,12 +27,12 @@ EXTERNAL SOURCES:
:path: Flutter

SPEC CHECKSUMS:
facebook_app_events: cfa07e73912a052992b5f218f79a19a66a99bf1a
facebook_app_events: 58a1b62fd50f6009907bd167fc26b3d043e97197
FBAEMKit: e34530df538b8eb8aeb53c35867715ba6c63ef0c
FBSDKCoreKit: d3f479a69127acebb1c6aad91c1a33907bcf6c2f
FBSDKCoreKit_Basics: 017b6dc2a1862024815a8229e75661e627ac1e29
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d

COCOAPODS: 1.16.2
12 changes: 6 additions & 6 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -377,7 +377,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -441,7 +441,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -490,7 +490,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -513,7 +513,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -544,7 +544,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
Loading