mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Merge pull request #359 from devgeeks/SMSComposer-update
SMSComposer updated for 1.4.x
This commit is contained in:
@@ -8,9 +8,14 @@ Using this plugin requires [PhoneGap for iPhone](http://github.com/phonegap/phon
|
||||
1. Add the SMSComposer.h and SMSComposer.m files to your "Plugins" folder in your PhoneGap project
|
||||
2. Add the SMSComposer.js files to your "www" folder on disk, and add a reference to the .js file after phonegap.js.
|
||||
3. Add the MessageUI framework to your Xcode project. In Xcode 4, double-click on the target, select "Build Phases" -> "Link Binary with Libraries" -> "+" and select "MessageUI.framework".
|
||||
4. Add the plugin to the PhoneGap.plist under Plugins (key: "SMSComposer" value: "SMSComposer")
|
||||
|
||||
## RELEASE NOTES ##
|
||||
|
||||
###20120219 ###
|
||||
* Fix for deprecations in PhoneGap 1.4.x
|
||||
* Added PhoneGap.plist instructions in README.md
|
||||
|
||||
### 201101112 ###
|
||||
* Initial release
|
||||
* Adds SMS text message composition in-app.
|
||||
@@ -20,32 +25,33 @@ Using this plugin requires [PhoneGap for iPhone](http://github.com/phonegap/phon
|
||||
## EXAMPLE USAGE ##
|
||||
|
||||
* All parameters are optional.
|
||||
window.plugins.smsComposer.showSMSComposer();
|
||||
`window.plugins.smsComposer.showSMSComposer();`
|
||||
|
||||
|
||||
* Passing phone number and message.
|
||||
window.plugins.smsComposer.showSMSComposer('3424221122', 'hello');
|
||||
`window.plugins.smsComposer.showSMSComposer('3424221122', 'hello');`
|
||||
|
||||
* Multiple recipents are separated by comma(s).
|
||||
window.plugins.smsComposer.showSMSComposer('3424221122,2134463330', 'hello');
|
||||
`window.plugins.smsComposer.showSMSComposer('3424221122,2134463330', 'hello');`
|
||||
|
||||
|
||||
* showSMSComposerWithCB takes a callback as its first parameter.
|
||||
* `showSMSComposerWithCB` takes a callback as its first parameter.
|
||||
* 0, 1, 2, or 3 will be passed to the callback when the text message has been attempted.
|
||||
|
||||
window.plugins.smsComposer.showSMSComposerWithCB(function(result){
|
||||
```javascript
|
||||
window.plugins.smsComposer.showSMSComposerWithCB(function(result){
|
||||
|
||||
if(result == 0)
|
||||
alert("Cancelled");
|
||||
else if(result == 1)
|
||||
alert("Sent");
|
||||
else if(result == 2)
|
||||
alert("Failed.");
|
||||
else if(result == 3)
|
||||
alert("Not Sent.");
|
||||
|
||||
},'3424221122,2134463330', 'hello');
|
||||
if(result == 0)
|
||||
alert("Cancelled");
|
||||
else if(result == 1)
|
||||
alert("Sent");
|
||||
else if(result == 2)
|
||||
alert("Failed.");
|
||||
else if(result == 3)
|
||||
alert("Not Sent.");
|
||||
|
||||
},'3424221122,2134463330', 'hello');
|
||||
````````
|
||||
|
||||
* A fully working example as index.html has been added to this repository.
|
||||
* It is an example of what your www/index.html could look like.
|
||||
@@ -9,6 +9,12 @@
|
||||
|
||||
@implementation SMSComposer
|
||||
|
||||
-(PGPlugin*) initWithWebView:(UIWebView*)theWebView
|
||||
{
|
||||
self = (SMSComposer*)[super initWithWebView:theWebView];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)showSMSComposer:(NSArray*)arguments withDict:(NSDictionary*)options
|
||||
{
|
||||
|
||||
@@ -45,7 +51,7 @@
|
||||
if(toRecipientsString != nil)
|
||||
[picker setRecipients:[ toRecipientsString componentsSeparatedByString:@","]];
|
||||
|
||||
[[ super appViewController ] presentModalViewController:picker animated:YES];
|
||||
[self.viewController presentModalViewController:picker animated:YES];
|
||||
[picker release];
|
||||
|
||||
}
|
||||
@@ -72,7 +78,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
[[ super appViewController ] dismissModalViewControllerAnimated:YES];
|
||||
[self.viewController dismissModalViewControllerAnimated:YES];
|
||||
|
||||
NSString* jsString = [[NSString alloc] initWithFormat:@"window.plugins.smsComposer._didFinishWithResult(%d);",webviewResult];
|
||||
[self writeJavascript:jsString];
|
||||
|
||||
Reference in New Issue
Block a user