| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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<dynamic> _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<void> saveAuthToken(String token) async {
- // 通知iOS键盘扩展
- if (Platform.isIOS) {
- _channel.invokeMethod('saveAuthToken', {'token': token});
- }
- }
- // 保存idfv到ios端
- static Future<void> saveIDFV(String? idfv) async {
- // 通知iOS键盘扩展
- if (Platform.isIOS) {
- _channel.invokeMethod('saveIDFV', {'idfv': idfv});
- }
- }
- // 保存idfa到ios端
- static Future<void> saveIDFA(String? idfa) async {
- // 通知iOS键盘扩展
- if (Platform.isIOS) {
- _channel.invokeMethod('saveIDFA', {'idfa': idfa});
- }
- }
- // 保存token到ios端
- static Future<void> clearAuthToken() async {
- // 通知iOS键盘扩展
- if (Platform.isIOS) {
- _channel.invokeMethod('clearAuthToken');
- }
- }
- }
|