import 'dart:io'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:keyboard/module/character_custom/character_custom_page.dart'; import 'package:keyboard/module/login/login_page.dart'; import 'package:keyboard/module/main/main_page.dart'; import 'package:keyboard/module/store/store_page.dart'; import '../module/intimacy_scale/intimacy_scale_page.dart'; class MethodChanelIOSUtil { static final MethodChanelIOSUtil _instance = MethodChanelIOSUtil._internal(); factory MethodChanelIOSUtil() => _instance; MethodChanelIOSUtil._internal(); static const MethodChannel _channel = MethodChannel('keyboard_ios'); static void initialize() { _channel.setMethodCallHandler(_handleMethod); } static Future _handleMethod(MethodCall call) async { switch (call.method) { case 'navigateToLogin': LoginPage.start(); break; case 'navigateToMember': StorePage.start(); break; case 'navigateToCharacterMarket': MainPage.start(arguments: {"tabName": "character"}); break; case 'navigateToCustomCharacter': CharacterCustomPage.start(); break; case 'navigateToIntimacy': IntimacyScalePage.start(); break; default: throw PlatformException( code: 'Unimplemented', details: '未实现的方法: ${call.method}', ); } } // 保存token到ios端 static Future saveAuthToken(String token) async { // 通知iOS键盘扩展 if (Platform.isIOS) { _channel.invokeMethod('saveAuthToken', {'token': token}); } } // 保存idfv到ios端 static Future saveIDFV(String? idfv) async { // 通知iOS键盘扩展 if (Platform.isIOS) { _channel.invokeMethod('saveIDFV', {'idfv': idfv}); } } // 保存idfa到ios端 static Future saveIDFA(String? idfa) async { // 通知iOS键盘扩展 if (Platform.isIOS) { _channel.invokeMethod('saveIDFA', {'idfa': idfa}); } } // 保存token到ios端 static Future clearAuthToken() async { // 通知iOS键盘扩展 if (Platform.isIOS) { _channel.invokeMethod('clearAuthToken'); } } }