Flutter Dexchange SMS
用于使用 Dexchange SMS API 发送短信的 Flutter 包
特点
- 发送短信
- 发送一次性密码 (OTP)
- 验证 OTP
安装
- 将最新版本的包添加到您的 pubspec.yaml 文件中 (并运行
flutter pub get flutter_dexchange_sms)
dependencies:
flutter_dexchange_sms: ^0.0.1
- 导入包并在您的 Flutter 应用中使用它。
import 'package:flutter_dexchange_sms/flutter_dexchange_sms.dart';
用法
import 'package:flutter_dexchange_sms/flutter_dexchange_sms.dart';
FlutterDexchangeSms dexchangeSms = FlutterDexchangeSms(apiKey: 'YOUR API KEY');
// To send an sms
try {
SendSmsResponse response = dexchangeSms.sendSms(request: SendSmsRequest(
number: ["221777460452", "777460452"],
signature: "DSMS",
content: "YO\nCV ?"
));
} on DexchangeApiException catch(e) {
print(e.toString()); // Handle the exception here
}
// To send otp sms
try {
SendOTPResponse response = dexchangeSms.sendOTP(request: SendOTPRequest(
number: "221777460452",
service: "DEMO",
lang: "en" // this field is optional
));
} on DexchangeApiException catch(e) {
print(e.toString()); // Handle the exception here
}
// To verifty OTP
try {
SendVerifyOTPResponse response = dexchangeSms.sendVerifyOTP(request: SendVerifyOTPRequest(
number: "221777460452",
service: "DEMO",
otp: "214045"
));
} on DexchangeApiException catch(e) {
print(e.toString()); // Handle the exception here
}