CleverTap / clevertap-flutter

CleverTap Flutter SDK
Other
30 stars 43 forks source link

Ios Deeplinking issue #200

Closed ShashankSMayya closed 1 year ago

ShashankSMayya commented 1 year ago

I tried to follow the guide on enabling clevertap to handle deeplinks for ios this is my appdelegate code. But wehen I try to run the app I get this error.

Swift Compiler Error (Xcode): Argument type 'AppDelegate' does not conform to expected type 'CleverTapURLDelegate'
/Users/shashanksmayya/IdeaProjects/mello/ios/Runner/AppDelegate.swift:19:47

Swift Compiler Error (Xcode): Non-'@objc' method 'shouldHandleCleverTap(_:for:)' does not satisfy requirement of '@objc' protocol 'CleverTapURLDelegate'
/Users/shashanksmayya/IdeaProjects/mello/ios/Runner/AppDelegate.swift:35:13
import UIKit
import Flutter
import GoogleMaps
import CleverTapSDK
import clevertap_plugin

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {

  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    CleverTap.autoIntegrate()
    registerForPush()
    CleverTapPlugin.sharedInstance()?.applicationDidLaunch(options: launchOptions)
    CleverTap.sharedInstance()?.setUrlDelegate(self)

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  func registerForPush() {
        UNUserNotificationCenter.current().delegate = self
    }

    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
      completionHandler([.sound, .alert, .badge])
    }

 public func shouldHandleCleverTap(_ url: URL?, for channel: CleverTapChannel) -> Bool {
//        print("Handling URL: \(url!) for channel: \(channel)")
        return true
    }

}
nishant-clevertap commented 1 year ago

Hi @ShashankSMayya

As I can see your class does not conforms to CleverTapURLDelegate, you are getting this error. Make sure your class conforms to this protocol in order to use shouldHandleCleverTap method like -

@objc class AppDelegate: FlutterAppDelegate, CleverTapURLDelegate {
}
ShashankSMayya commented 1 year ago

Hey @nishant-clevertap Thanks for the help. Its sorted out now :)