diff --git a/.gitignore b/.gitignore
index 7bf00e8..4c70518 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ pubspec.lock
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
+.idea
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 30aa626..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
deleted file mode 100644
index df0a084..0000000
--- a/.idea/libraries/Dart_SDK.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml
deleted file mode 100644
index 53449da..0000000
--- a/.idea/libraries/Flutter_Plugins.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Flutter_for_Android.xml b/.idea/libraries/Flutter_for_Android.xml
deleted file mode 100644
index 4e96414..0000000
--- a/.idea/libraries/Flutter_for_Android.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 3268472..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index bfb9971..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/.idea/runConfigurations/example_lib_main_dart.xml b/.idea/runConfigurations/example_lib_main_dart.xml
deleted file mode 100644
index 5fd9159..0000000
--- a/.idea/runConfigurations/example_lib_main_dart.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/main_dart.xml b/.idea/runConfigurations/main_dart.xml
deleted file mode 100644
index aab7b5c..0000000
--- a/.idea/runConfigurations/main_dart.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 25bed21..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,259 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1534353795796
-
-
- 1534353795796
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ios/Classes/SwiftFlutterSmsPlugin.swift b/ios/Classes/SwiftFlutterSmsPlugin.swift
index a1596a2..acb1042 100644
--- a/ios/Classes/SwiftFlutterSmsPlugin.swift
+++ b/ios/Classes/SwiftFlutterSmsPlugin.swift
@@ -3,11 +3,11 @@ import UIKit
import MessageUI
public class SwiftFlutterSmsPlugin: NSObject, FlutterPlugin, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate {
- var message = "Please Send Message"
- var _arguments = [String: Any]()
+ var result: FlutterResult?
+ var _arguments = [String: Any]()
public static func register(with registrar: FlutterPluginRegistrar) {
- let channel = FlutterMethodChannel(name: "flutter_sms", binaryMessenger: registrar.messenger())
+ let channel = FlutterMethodChannel(name: "flutter_sms", binaryMessenger: registrar.messenger())
let instance = SwiftFlutterSmsPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
@@ -17,14 +17,14 @@ public class SwiftFlutterSmsPlugin: NSObject, FlutterPlugin, UINavigationControl
switch call.method {
case "sendSMS":
#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."))
+ 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
- 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)
- result(message)
+ 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)
#endif
default:
result(FlutterMethodNotImplemented)
@@ -33,7 +33,14 @@ public class SwiftFlutterSmsPlugin: NSObject, FlutterPlugin, UINavigationControl
}
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)
- message = "Sent!"
}
}