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

outdated

To provide developers with a global SMS verification code tool, developers can use this tool to insert the SMS verification code SDK in the app, and SMS verification can be achieved with simple Settin [...]

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:mob_smssdk/smssdk.dart' ;

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

var zoneController = new TextEditingController();
var phoneController = new TextEditingController();
var tempIDController = new TextEditingController();
var codeController = new TextEditingController();

  @override
  void initState() {
    super.initState();

  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('SMSSDK Flutter'),
        ),
        body: new Padding(
          padding: const EdgeInsets.all(10.0),
          child: Container(
            child: new ListView.builder(
              itemCount: 1,
              itemBuilder: (context, i)=> renderRow(i,context),
            ),
          ),
        ),
      ),
    );
  }

  void showAlert(String text, BuildContext context) {
    showDialog(
        context: context,
        builder: (BuildContext context) => AlertDialog(
                title: new Text("提示"),
                content: new Text(text),
                actions: <Widget>[
                  new FlatButton(
                    child: new Text("OK"),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  )
                ]));
  }

  Widget renderRow(i, BuildContext context){
    return new Column(
        
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            height: 30,
          ),
          Text('请先输入手机号'),
          TextField(
            controller: zoneController,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(15.0),
              labelText: '请输入国家 如:86',
            ),
          ),
          TextField(
            controller: phoneController,
            keyboardType: TextInputType.number,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(10.0),
              labelText: '请输入手机号'
            ),
          ),
          TextField(
            controller: tempIDController,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(10.0),
              labelText: '模板编号(没有则不填):'
            ),
          ),
          Container(
            height: 30,
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child:new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('请求文本验证码'),
            onPressed: (){

                Smssdk.getTextCode(phoneController.text, zoneController.text, tempIDController.text, (dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    String rst = ret.toString();
                    if (rst == null || rst == "") {
                      rst = '获取验证码成功!';
                    }
                    showAlert(rst,context);
                  }
                });
                
              },
            ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child:new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('请求语音验证码'),
            onPressed: (){
                 Smssdk.getVoiceCode(phoneController.text, zoneController.text, (dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert('获取验证码成功!',context);
                  }
                });
            },
          ),
          ),

          TextField(
            controller: codeController,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(10.0),
              labelText: '请输入验证码'
            ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child: new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('提交验证码'),
            onPressed: (){
                Smssdk.commitCode(phoneController.text, zoneController.text, codeController.text, (dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert('提交验证码成功!',context);
                  }
                });
            },
          ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child: new   FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('获取国家列表'),
            onPressed: (){
              Smssdk.getSupportedCountries((dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert(ret.toString(),context);
                  }
                });
            },
          ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child: new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('获取应用内好友'),
            onPressed: (){
              Smssdk.getFriends((dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert(ret.toString(),context);
                  }
                });
            },
          ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity),
            child: new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('提交用户信息'),
            onPressed: (){
                Smssdk.submitUserInfo("3241241", "SmsSDK_Flutter_User_3241241",
                    "http://download.sdk.mob.com/510/deb/0c0731ac543eb71311c482a2e2.png",
                    zoneController.text, phoneController.text, (dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert('提交用户信息 成功!',context);
                  }
                });
            },
          ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity), 
            child: new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('获取版本号'),
            onPressed: (){

              print("go go");
              Smssdk.getVersion((dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert(ret.toString(),context);
                  }
                });
            },
          ),
          ),
          ConstrainedBox(
            constraints: const BoxConstraints(minWidth: double.infinity), 
            child: new FlatButton(
            color: Colors.blueGrey,
            textColor: Colors.white,
            child: new Text('开启提示框'),
            onPressed: (){
              Smssdk.enableWarn(true,(dynamic ret, Map err){
                  if(err!=null)
                  {
                    showAlert(err.toString(),context);
                  }
                  else
                  {
                    showAlert('开启提示框 成功!',context);
                  }
                });
            },
          ),
          ),
           
        ],
      );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

To provide developers with a global SMS verification code tool, developers can use this tool to insert the SMS verification code SDK in the app, and SMS verification can be achieved with simple Settings. Quick integration, and easy management in the later stage.中文官网:http://sms.mob.com

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on mob_smssdk