2

我想在我的 FLutter 应用程序中使用simple_auth_flutter来针对 instagram 对用户进行身份验证。所以我按照文档页面并应用了所有更改。我尝试将上述行添加到我的 AppDelegate.swift 中,如下所示:

import UIKit
import Flutter
import SimpleAuth;

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
    override func application(_ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey : Any]?) -> Bool{
        return SimpleAuth.CheckUrl(url);
    }
}

当我尝试执行flutter run 时,我看到了错误:

no such module 'SimpleAuth' import SimpleAuth;

那么我应该怎么做才能解决AppDelegate中的导入呢?我的 pubspec.yml 使用:

simple_auth: ^2.0.7
simple_auth_flutter: ^2.0.7
4

1 回答 1

1

我想我找到了一个可以构建我的应用程序的解决方案。

import UIKit
import Flutter
import simple_auth_flutter;

@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(_ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey : Any]?) -> Bool{
        return SimpleAuthFlutterPlugin.check(url);
    }
}
于 2021-04-17T18:43:21.390 回答