update sms plugin

This commit is contained in:
2026-01-13 23:27:56 -08:00
parent 12fb3a2089
commit 33258c580c
131 changed files with 4299 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
/Flutter/flutter_export_environment.sh
@@ -0,0 +1,4 @@
#import <Flutter/Flutter.h>
@interface FlutterSmsPlugin : NSObject<FlutterPlugin>
@end
@@ -0,0 +1,8 @@
#import "FlutterSmsPlugin.h"
#import <flutter_sms/flutter_sms-Swift.h>
@implementation FlutterSmsPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
[SwiftFlutterSmsPlugin registerWithRegistrar:registrar];
}
@end
@@ -0,0 +1,72 @@
import Flutter
import UIKit
import MessageUI
public class SwiftFlutterSmsPlugin: NSObject, FlutterPlugin, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate {
var result: FlutterResult?
var _arguments = [String: Any]()
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "flutter_sms", binaryMessenger: registrar.messenger())
let instance = SwiftFlutterSmsPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "sendSMS":
_arguments = call.arguments as! [String : Any];
#if targetEnvironment(simulator)
result(FlutterError(
code: "message_not_sent",
message: "Cannot send message on this device!",
details: "Cannot send SMS and MMS on a Simulator. Test on a real device."
)
)
#else
if (MFMessageComposeViewController.canSendText()) {
self.result = result
let controller = MFMessageComposeViewController()
controller.body = _arguments["message"] as? String
controller.recipients = _arguments["recipients"] as? [String]
controller.messageComposeDelegate = self
UIApplication.shared.keyWindow?.rootViewController?.present(controller, animated: true, completion: nil)
} else {
result(FlutterError(
code: "device_not_capable",
message: "The current device is not capable of sending text messages.",
details: "A device may be unable to send messages if it does not support messaging or if it is not currently configured to send messages. This only applies to the ability to send text messages via iMessage, SMS, and MMS."
)
)
}
#endif
case "canSendSMS":
#if targetEnvironment(simulator)
result(false)
#else
if (MFMessageComposeViewController.canSendText()) {
result(true)
} else {
result(false)
}
#endif
default:
result(FlutterMethodNotImplemented)
break
}
}
public func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
let map: [MessageComposeResult: String] = [
MessageComposeResult.sent: "sent",
MessageComposeResult.cancelled: "cancelled",
MessageComposeResult.failed: "failed",
]
if let callback = self.result {
callback(map[result])
}
UIApplication.shared.keyWindow?.rootViewController?.dismiss(animated: true, completion: nil)
}
}
@@ -0,0 +1,23 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint flutter_sms.podspec' to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'flutter_sms'
s.version = '1.1.0'
s.summary = 'A Flutter plugin for Sending SMS on Android and iOS.'
s.description = <<-DESC
A new flutter plugin project.
DESC
s.homepage = 'https://github.com/fluttercommunity/flutter_sms'
s.license = { :file => '../LICENSE' }
s.author = { 'Rody Davis' => 'rody.davis.jr@gmail.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
end