voximplant / flutter_callkit

Flutter SDK for CallKit integration to Flutter applications on iOS
MIT License
53 stars 19 forks source link

Instance member 'reportNewIncomingCall' cannot be used on type 'FlutterCallkitPlugin'; did you mean to use a value of this type instead? #6

Closed kadariyaujwal closed 3 years ago

kadariyaujwal commented 3 years ago

Hi I get this Error in IOS. Please help

Instance member 'reportNewIncomingCall' cannot be used on type 'FlutterCallkitPlugin'; did you mean to use a value of this type instead?

Here is my app delegate.swift

import UIKit
import Flutter
import PushKit                     /* <------ add this line */
import flutter_voip_push_notification
import flutter_callkit_voximplant
import CallKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate {
   // Handle incoming pushes
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
        // Process the received push
        FlutterVoipPushNotificationPlugin.didUpdate(pushCredentials, forType: type.rawValue);
    }

  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    // if #available(iOS 10.0, *) {
    //   UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    // }
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
    func pushRegistry(_ registry: PKPushRegistry,
                      didReceiveIncomingPushWith payload: PKPushPayload,
                      for type: PKPushType
    ) {
        processPush(with: payload.dictionaryPayload, and: nil)
    }

    func pushRegistry(_ registry: PKPushRegistry,
                      didReceiveIncomingPushWith payload: PKPushPayload,
                      for type: PKPushType,
                      completion: @escaping () -> Void
    ) {
        processPush(with: payload.dictionaryPayload, and: completion)
    }

    private func processPush(with payload: Dictionary<AnyHashable, Any>,
                             and completion: (() -> Void)?
    ) {
        // 3. get uuid and other needed information from payload
        guard let uuidString = payload["uuid"] as? String,
            let uuid = UUID(uuidString: uuidString),
            let localizedName = payload["callerName"] as? String
            else {
                return
        }
        // 4. prepare call update
        let callUpdate = CXCallUpdate()
        callUpdate.localizedCallerName = localizedName
        // 5. prepare provider configuration
        let configuration = CXProviderConfiguration(localizedName: "JPAL")
        // 6. send it to the plugin
        FlutterCallkitPlugin.reportNewIncomingCall(
            with: uuid,
            callUpdate: callUpdate,
            providerConfiguration: configuration,
            pushProcessingCompletion: completion
        )
    }
}
VladimirBrejcha commented 3 years ago

Hello kadariyaujwal, Due to API changes in 1.2.0, "reportNewIncomingCall" is now an instance method. To achieve the same behaviour as before, instead of "FlutterCallkitPlugin.reportNewIncomingCall" you need to call "FlutterCallkitPlugin.sharedInstance.reportNewIncomingCall".

README example will be fixed asap, thank you for letting me know