flyverify_noui 0.0.4 copy "flyverify_noui: ^0.0.4" to clipboard
flyverify_noui: ^0.0.4 copied to clipboard

mob 秒验 登录插件(三大运营商手机号直接登录)

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flyverify_noui/flyverify_noui.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _log = '';

  @override
  void initState() {
    super.initState();
    initPlatformState();
    if(Platform.isIOS){
      FlyverifyNoui.init(key: 'xxx', secret: 'xxxxxxxxx', privacyLevel: 2);
    }
  }

  /// 初始化平台信息
  Future<void> initPlatformState() async {
    try {
      final version = await FlyverifyNoui.getPlatformVersion();
      setState(() {
        _platformVersion = version ?? 'Unknown platform version';
      });
    } on PlatformException catch (e) {
      setState(() {
        _platformVersion = 'Error: ${e.message}';
      });
    }
  }

  /// 添加日志
  void _addLog(String msg) {
    setState(() {
      _log += '${DateTime.now().toIso8601String()} - $msg\n';
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlyverifyNoui 测试'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16),
          child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('Platform Version: $_platformVersion'),
                const SizedBox(height: 12),
                Wrap(
                  spacing: 10,
                  runSpacing: 10,
                  children: [
                    ElevatedButton(
                      onPressed: () async {
                        try {
                          await FlyverifyNoui.submitPolicyGrantResult(true);
                          _addLog('提交隐私授权结果: true');
                        } catch (e) {
                          _addLog('submitPolicyGrantResult 失败: $e');
                        }
                      },
                      child: const Text('提交隐私授权 (同意)'),
                    ),
                    ElevatedButton(
                      onPressed: () async {
                        try {
                          await FlyverifyNoui.submitPolicyGrantResult(false);
                          _addLog('提交隐私授权结果: false');
                        } catch (e) {
                          _addLog('submitPolicyGrantResult 失败: $e');
                        }
                      },
                      child: const Text('提交隐私授权 (拒绝)'),
                    ),
                    ElevatedButton(
                      onPressed: () async {
                        try {
                          final result = await FlyverifyNoui.preVerify();
                          _addLog('预取号结果: $result');
                        } catch (e) {
                          _addLog('preVerify 失败: $e');
                        }
                      },
                      child: const Text('预取号'),
                    ),
                    ElevatedButton(
                      onPressed: () async {
                        try {
                          final result = await FlyverifyNoui.mobLogin();
                          _addLog('获取 token: $result');
                        } catch (e) {
                          _addLog('mobLogin 失败: $e');
                        }
                      },
                      child: const Text('获取 token'),
                    ),
                    ElevatedButton(
                      onPressed: () async {
                        try {
                          await FlyverifyNoui.init(
                            key: 'your_key',
                            secret: 'your_secret',
                            privacyLevel: 1, // 假设 1 表示已同意
                          );
                          _addLog('SDK 初始化完成');
                        } catch (e) {
                          _addLog('init 失败: $e');
                        }
                      },
                      child: const Text('初始化 SDK (iOS专用)'),
                    ),
                  ],
                ),
                const SizedBox(height: 20),
                const Text('日志输出:'),
                Container(
                  width: double.infinity,
                  padding: const EdgeInsets.all(8),
                  color: Colors.grey.shade200,
                  height: 300,
                  child: SingleChildScrollView(
                    child: Text(
                      _log,
                      style: const TextStyle(fontSize: 12),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
135
points
120
downloads

Publisher

unverified uploader

Weekly Downloads

mob 秒验 登录插件(三大运营商手机号直接登录)

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flyverify_noui

Packages that implement flyverify_noui