2012-03-30 101 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