2012-03-30 103 views
2

是否有可能在iphone中使用phonegap发送短信?如果是的话,任何人都可以建议我使用示例代码或教程吗?从iPhone手机发送短信?

是否有可能在iPhone中使用phonegap找出用户的电话号码??如果有人可以建议我示例代码或教程这样做?

回答

2

如果你想通过手机发送短信首先应该创建一个插件(见PhoneGap的网站,看看如何做),然后在插件代码(应该是本地代码做这样的:

您必须添加的MFMessageComposeViewController在你的头文件MessageUI.framework到您的Xcode项目,包括#import <MessageUI/MessageUI.h>

这些委托添加到您的头文件MFMessageComposeViewControllerDelegate & UINavigationControllerDelegate。 在你IBAction为方法声明实例说messageInstance检查你的设备是否可以发送文本使用[MFMessageComposeViewController canSendText],如果条件下,它会返回是/否在if条件做这些:

MFMessageComposeViewController *messageInstance = [[[MFMessageComposeViewController alloc] init] autorelease]; 
// set body for your messageInstance 
messageInstance.body = @"Hello from Shah"; 
// then decide the recipients for the message as: 
messageInstance.recipients = [NSArray arrayWithObjects:@"12345678", @"87654321",   nil]; 
//Set a delegate to your messageInstance as: 
messageInstance.messageComposeDelegate = self; 

// Then present the messageViewController 
[self messageInstance animated:YES]; 
+0

嘿谢谢你的帮助..我试试吧 – user1285402 2012-03-30 09:13:09

5

link为您提供有关如何发送使用的PhoneGap的iPhone短信的完整描述。

+0

嘿非常感谢你帮助我 – user1285402 2012-03-30 09:15:16

+0

@ user1285402欢迎:) – KingofBliss 2012-03-30 09:16:07

+0

那个链接已经死了现在天:/ – Jacksonkr 2014-01-14 15:33:52