As specified in our plugin.xml
file's platform section for iOS, the implementation of our plugin in iOS is located at the src/ios/Sms.h
and src/ios/Sms.m
Objective-C files. The following code snippet shows the Sms.h
file (the header file):
#import <Cordova/CDV.h> #import <MessageUI/MFMessageComposeViewController.h> @interface Sms : CDVPlugin <MFMessageComposeViewControllerDelegate> { } @property(strong) NSString* callbackID; - (void)sendMessage:(CDVInvokedUrlCommand*)command; @end
The preceding code declares an Sms
class that extends CDVPlugin
. It is important to note that in order to create a Cordova iOS plugin class, our Objective-C plugin class must extend the CDVPlugin
class. In our Sms
class declaration, there is a declared callbackID
property of the NSString
type and a declared sendMessage
method, which returns void
and takes CDVInvokedUrlCommand
as a parameter. Now, let's move on to the Sms
class implementation. The following code snippet shows...