Closed supposedlysam-bb closed 3 years ago
Hey @supposedlysam-bb Thanks for the feedback.
I've updated the guides doc for Kotlin/swift support, please find it here: https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/Guides.md
When creating a kotlin/swift app the only thing needed to be added is the deeplink handling: Life-cycles for iOS and the onNewIntent method for android.
Please let us know if you've encountered any specific issue on the matter.
Thank you! I really appreciate the help!
I also noticed there is some additional setup in the github readme that isn't in the Flutter guides. Does the additional setup for iOS 14 also need to be done for the Flutter app?
Also, is there a different import for Swift? Looks like the only Module it can find is the AppsFlyerLib
module. I would think I should switch out all AppsFlyerAttribution
references with AppsFlyerLib
; is that correct?
Based on the docs, this is what I've added but it doesn't know what AppsFlyerAttribution
is. Replacing it with AppsFlyerLib
results in an error saying, Cannot force unwrap value of non-optional type 'AppsFlyerLib'
. Removing the exclamation point results in many more errors. Would you be able to create an example project with Swift and Kotlin so I can pull from there?
import UIKit
import Flutter
import AppsFlyerLib
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
AppsFlyerAttribution.shared()!.handleOpenUrl(url, sourceApplication: sourceApplication, annotation: annotation);
return true
}
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
AppsFlyerAttribution.shared()!.handleOpenUrl(url, options: options)
return true
}
private func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
AppsFlyerAttribution.shared()!.continueUserActivity(userActivity, restorationHandler: nil)
return true
}
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
AppsFlyerAttribution.shared()!.continueUserActivity(userActivity, restorationHandler: nil)
return true
}
}
Errors after replacing with Lib and removing exclamations
Hey @supposedlysam-bb,
Because of the plugins limitation, the flutter iOS is "waking up" later then the native iOS SDK. Because of that we've provided a workaround and implemented a different import in IOS (It's the reason we've implemented the "AppsFlyerAttribution"). Please make sure to use "#import "AppsflyerSdkPlugin.h" in the "Runner-Bridging-Header.h" file and the "AppsFlyerAttribution" should be recognized.
Regarding iOS 14, yes, it should be implemented in swift as well. This is Apple API (not appsflyer) that is in charge of calling the consent dialog for the user. I will make sure to add the swift version to our flutter docs as well. For now, find the swift implementation in the following article under the section "3.3 Configuring App Tracking Transparency (ATT) supportCopy direct link": https://support.appsflyer.com/hc/en-us/articles/207032066#integration-33-configuring-app-tracking-transparency-att-support
After adding the import to the Runner-Bridging-Header.h
file and removing the import to AppsFlyerLib
from the AppDelegate.swift
I was able to get it to build successfully; only to immediately crash with an error:
-[NSNull doubleValue]: unrecognized selector sent to instance 0x1e2c10a00
That backtraces to the line 428 of the AppsFlyerSdkPlugin
timeToWaitForATTUserAuthorization = [(id)call.arguments[afTimeToWaitForATTUserAuthorization] doubleValue];
More setup I'm missing maybe?
In addition to the above changes, setting the timeToWaitForATTUserAuthorization
on the AppsFlyerOptions I pass to the AppsFlyerSdk seemed to get me past this error!
Documentation Enhancement
Swift and Kotlin setup alternatives severely needed
As myself and my team come from a web background, none of us know how to convert the Objective-C and Java code provided in your guides to the appropriate Swift and Kotlin alternative; effectively blocking us from integrating with the appsflyer sdk plugin.
Please update your guide to include alternatives for both Swift and Kotlin!