Files
fanuzu/app/ios/Runner/AppDelegate.swift
T

37 lines
1.7 KiB
Swift

import Flutter
import GoogleMaps
import UIKit
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// 구글 지도 키 — ios/config/Maps.xcconfig → Info.plist. 없으면 지도만 비고 앱은 정상이다.
if let key = Bundle.main.object(forInfoDictionaryKey: "GMSApiKey") as? String, !key.isEmpty {
GMSServices.provideAPIKey(key)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
// 국가 표시명 — 앱 언어로 OS 가 아는 이름을 OS 정렬 순서로 준다(Dart `loadCountryNames`). `[[코드, 이름], …]`.
guard let registrar = engineBridge.pluginRegistry.registrar(forPlugin: "FanuzuLocale") else { return }
FlutterMethodChannel(name: "kr.co.fanuzu.app/locale", binaryMessenger: registrar.messenger())
.setMethodCallHandler { call, result in
guard call.method == "countryNames" else {
result(FlutterMethodNotImplemented)
return
}
let tag = (call.arguments as? [String: Any])?["locale"] as? String ?? "ko"
let locale = Locale(identifier: tag)
let pairs: [[String]] = Locale.isoRegionCodes
.compactMap { code in locale.localizedString(forRegionCode: code).map { [code, $0] } }
.sorted { $0[1].compare($1[1], locale: locale) == .orderedAscending }
result(pairs)
}
}
}