xcode 如何在不启动文本应用程序的情况下发送短信?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2619009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:16:44  来源:igfitidea点击:

How do I send SMS without launching Text application?

xcodeiphone-sdk-3.0sms

提问by Thomas

I am developing a simple application which has to send an SMS message from the app itself instead of launching the native Text app.

我正在开发一个简单的应用程序,它必须从应用程序本身发送 SMS 消息,而不是启动本机文本应用程序。

Here's my action now. What should I change to achieve my desired functionality?

这是我现在的行动。我应该改变什么来实现我想要的功能?

-(IBAction)startButtonPressed
{
    NSString *phoneNumber = @"13136296693";
    NSString *url           = [NSString stringWithFormat: @"sms:%@",phoneNumber];
    NSLog(@"Send SMS to: %@ ", url); 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

Thanks!

谢谢!

Thomas

托马斯

采纳答案by Noah Witherspoon

Can't be done with the current SDK. I believe Apple announced that applications in iPhone OS 4.0 will be able to do this, using a similar interface to the existing MFMailComposeViewControllermalarkey.

不能用当前的 SDK 完成。我相信 Apple 宣布 iPhone OS 4.0 中的应用程序将能够做到这一点,使用与现有MFMailComposeViewControllerMalarkey类似的界面。

回答by Hyman Marchetti

If I'm not mistaken I think sending text messages via your own application is only available in the iPhone 4.0 SDK.

如果我没记错的话,我认为通过您自己的应用程序发送短信只能在 iPhone 4.0 SDK 中使用。

回答by Joe C

Here's what apple says:

这是苹果说的:

https://web.archive.org/web/20140604143837/http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/SystemMessaging_TopicsForIOS/Articles/SendinganSMSMessage.html

https://web.archive.org/web/20140604143837/http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/SystemMessaging_TopicsForIOS/Articles/SendinganSMSMessage.html

Here's a tutorial fon another forum.

这是另一个论坛的教程。

http://iosdevelopertips.com/core-services/how-to-send-an-sms-progammatically.html

http://iosdevelopertips.com/core-services/how-to-send-an-sms-progammatically.html

It's still not entirely automated. The user has to tap the send button. I haven't gotten it working yet. Tell me if you have better luck. If you can think of a way for me to program my app to "tap" the send button instead of the user, let me know.

它仍然不是完全自动化的。用户必须点击发送按钮。我还没有让它工作。告诉我你是否有更好的运气。如果您能想出一种方法让我对我的应用程序进行编程以“点击”发送按钮而不是用户,请告诉我。