Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kadariyaujwal opened this issue Jan 17, 2021 · 1 comment

Comments

@kadariyaujwal
Copy link

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
Copy link
Contributor

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

VladimirBrejcha added a commit that referenced this issue Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants