GetMetaMap / metamap-flutter-plugin

Flutter plugin for Mati SDK
MIT License
2 stars 8 forks source link

Could not find module 'MatiSDK' for target 'armv7-apple-ios'; #3

Closed darwin-morocho closed 3 years ago

darwin-morocho commented 3 years ago

Hi, I am trying to run the project using xcode 12.5.1 on my iPhone X with iOS 14.6 and I am having the next error

Could not find module 'MatiSDK' for target 'armv7-apple-ios'; found: x86_64-apple-ios-simulator, arm64, x86_64, arm64-apple-ios

It works fine if I use a iPhone 12 (simulator)

darwin-morocho commented 3 years ago

@aposnovmati please your help with this.

aposnovmati commented 3 years ago

Hello, @darwin-morocho could you try the latest version, is it actual issue?

darwin-morocho commented 3 years ago

Hello, @darwin-morocho could you try the latest version, is it actual issue?

currently I am not using this plugin, I decided to use Platform Channels with a better implementation without a static completer.

import 'package:flutter/services.dart';

class MatiSDK {
  final _channel = const MethodChannel('channel_name');

  /// show the mati UI flow
  ///
  /// return null if the verification was cancelled or any error happened
  Future<String?> showFlow({
    required String clientId,
    required String flowId,
    required Map<String, dynamic> metadata,
  }) async {
    try {
      final identityId = await _channel.invokeMethod<String>(
        "showMatiFlow",
        {
          'clientId': clientId,
          'flowId': flowId,
          'metadata': metadata,
        },
      );
      return identityId;
    } catch (e) {
      print("❌ matiSDK error:: $e");
      return null;
    }
  }
}
package com.criptan.app.criptan_app.platform_channels

import android.app.Activity
import android.content.Intent
import com.getmati.mati_sdk.MatiSdk
import com.getmati.mati_sdk.Metadata
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

class MatiPlatformChannel(private val activity: Activity, private val messenger: BinaryMessenger) :
    MethodChannel.MethodCallHandler {

    private val CHANNEL_NAME = "channel_name"

    private lateinit var channel: MethodChannel
    private var pendingResult: MethodChannel.Result? = null

    init {
        val channel = MethodChannel(messenger, CHANNEL_NAME)
        channel.setMethodCallHandler(this)
    }

    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
        when (call.method) {
            "showMatiFlow" -> {
                showMatiFlow(call, result)
            }
            else -> result.notImplemented()
        }
    }

    private fun showMatiFlow(call: MethodCall, result: MethodChannel.Result) {

        if (pendingResult != null) {
            pendingResult!!.error("PENDING_TASK", "you have a previous request", null)
            pendingResult = null
            return
        }

        val clientId = call.argument<String>("clientId")!!
        val flowId = call.argument<String?>("flowId")
        val metadata = call.argument<Map<String, Any>?>("metadata")

        pendingResult = result

        val matiMetaData = Metadata.Builder().apply {
            metadata?.entries?.forEach {
                this.with(it.key, it.value)
            }
        }.build()

        activity.let { activity ->
            MatiSdk.startFlow(
                activity, clientId, flowId, matiMetaData
            )
        }

    }

    fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == MatiSdk.REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK) {
                val identityId = data!!.getStringExtra("ARG_VERIFICATION_ID")
                pendingResult?.success(identityId)
                pendingResult = null
            } else {
                pendingResult?.success(null)
                pendingResult = null
            }
        }
    }
}
import Foundation
import Flutter
import MatiSDK

class MatiPlatformChannel: NSObject,MatiButtonResultDelegate {

    var channel: FlutterMethodChannel!
    let channelName = "channel_name"
    var pendingResult: FlutterResult?

    init(messenger:FlutterBinaryMessenger) {
        super.init()
        self.channel = FlutterMethodChannel(name: channelName, binaryMessenger: messenger)
        self.channel.setMethodCallHandler(self.callHandler)
        MatiButtonResult.shared.delegate = self
    }

    private func callHandler(call:FlutterMethodCall, result:@escaping FlutterResult){
        switch call.method {
        case "showMatiFlow":
            showMatiFlow(call: call, result: result)

        default:
            result(FlutterMethodNotImplemented)
        }
    }

    private func showMatiFlow(call:FlutterMethodCall , result:@escaping FlutterResult){
        if pendingResult != nil {
            result(FlutterError(code: "PENDING_TASK", message: "you have a previous request", details: nil))
            pendingResult = nil
            return
        }
        let arguments = (call.arguments as! [String: Any])
        let clientId = arguments["clientId"] as! String
        let flowId = arguments["flowId"] as? String
        let metadata = arguments["metadata"] as? [String : Any]

        MatiSDK.shared.showMatiFlow(clientId: clientId,
                                    flowId: flowId,
                                    metadata: metadata)

        pendingResult = result
    }

    func verificationSuccess(identityId: String) {
        self.pendingResult!(identityId)
        self.pendingResult = nil
    }

    func verificationCancelled() {
        self.pendingResult!(nil)
        self.pendingResult = nil
    }

}

I think this should be a better implementation for this plugin because it is more simple using a Future in the dart side.

aleksei-klyshnikov-mati commented 3 years ago

Dear @darwin-morocho, thank you for provided solution we will be moving forward to similar Implementation at the end of Q32021. For now I've updated our current solution and version 3.3.1 should work as well