AppsFlyerSDK / appsflyer-flutter-plugin

Flutter Plugin for AppsFlyer SDK
MIT License
148 stars 119 forks source link

Please provide direction for AppDelegate.swift in the tutorial #137

Closed cesariomartins closed 3 years ago

cesariomartins commented 3 years ago

Around Flutter 1.17, the framework switched from generating Objective C files to Swift files by default. So, in my code there is only AppDelegate.swift. The file AppDelegate.m is not there.

In the Appsflyer tutorial (https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/Guides.md) there is information on what to do in the AppDelegate.m file but no info on what to do in the AppDelegate.swift file. The same for the example in the example folder.

Please provide direction on what to do in the AppDelegate.swift.

Tks

GM-appsflyer commented 3 years ago

Hey @cesariomartins ,

Are you referring to the Set plugin for IOS 14 section? If yes, this is Apple's class and methods. For now the offical implementation could be found here: https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager https://dev.appsflyer.com/hc/docs/integrate-ios-sdk#enabling-app-tracking-transparency-att-support Either way, I will make sure to add it to the docs soon.

I can see that the deeplink doc part include swift with our API.

Please let us know if there is anything else!

cesariomartins commented 3 years ago

@GM-appsflyer, tks for the response.

I am referring to this guide (https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/Guides.md) and also to this example AppDelegate.m (https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/example/ios/Runner/AppDelegate.m).

The guide does not help me configuring the AppDelegate.swift. The guide and the example are better designed for AppDelegate.m which is not the standard anymore.

For example, I tried configuring the AppDelegate.swift like the following:

import UIKit
import Flutter
#import "AppsflyerSdkPlugin.h"

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    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
    }
}

But received the two errors below: error: expected expression #import "AppsflyerSdkPlugin.h" error: cannot find 'AppsFlyerAttribution' in scope AppsFlyerAttribution.shared()!.handleOpenUrl(url, sourceApplication: sourceApplication, annotation: annotation);

Please advise on how my AppDelegate.swift should be configured. Tks

GM-appsflyer commented 3 years ago

Hey @cesariomartins ,

I've added to the docs swit code and example. Please find it here: https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/Guides.md#Example-swift

cesariomartins commented 3 years ago

many tks