gpt4 book ai didi

iphone - 从 iPhone 中的 PhoneGap 发送短信?

转载 作者:行者123 更新时间:2023-12-03 21:03:50 25 4
gpt4 key购买 nike

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

是否可以在 iPhone 中使用 PhoneGap 找出用户的电话号码?如果可以,有人可以建议我示例代码或教程吗???

最佳答案

如果您想首先通过电话发送短信,您应该创建一个插件(请参阅phonegap网站以了解其完成方式),然后在插件代码中(它应该是 native 代码,这样做:

您必须将 MessageUI.framework 添加到 Xcode 项目中,并在头文件中包含 #import <MessageUI/MessageUI.h>

将这些委托(delegate)添加到您的头文件 MFMessageComposeViewControllerDelegateUINavigationControllerDelegate 中。在您的 IBAction 方法中声明 MFMessageComposeViewController 的实例,例如 messageInstance 来检查您的设备是否可以在 if 条件中使用 [MFMessageComposeViewController canSendText] 发送文本,它将在 if 条件中返回 Yes/No 执行以下操作:

 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];

关于iphone - 从 iPhone 中的 PhoneGap 发送短信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9939601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com