【问题标题】:iOS change SMSC programmaticallyiOS 以编程方式更改 SMSC
【发布时间】:2012-03-19 17:28:43
【问题描述】:

我正在编写一个可以测试来自运营商的不同 SMSC(短消息服务中心)的应用程序。因此,我需要更改 iPhone 用于发送 SMS 的 SMSC。有没有办法做到这一点?

Android 提供了一个以 SMSC 作为参数的 sendMessage 方法,iOS 中是否有等效方法?我不在乎它是否使用私有 API 调用,因为无论如何我都不会发布我的应用程序(仅用于内部测试目的)。任何帮助表示赞赏,谢谢。

【问题讨论】:

  • 作为替代方案,它可以是更改 iPhone 正在使用的 SMSC 的代码,而不是直接通过不同的 SMSC 发送。
  • 另一种选择是在后台调用 **5005*7672*SMSCNUMBER#,私有 API 中有这样的事情吗?

标签: iphone ios sms


【解决方案1】:

此解决方案适用于未越狱的手机,但不会进入应用商店。 它使用私有 API,与您对 Android 的 sendMessage 的描述非常相似。

您必须将您的项目链接到 CoreTelephony 框架(现已公开),并创建如下所述的标题。也包括示例。

CTMessageCenter.h:

#import <Foundation/Foundation.h>

@interface CTMessageCenter : NSObject
{
}

+ (id)sharedMessageCenter;
- (id)init;
- (id)sendSMS:(id)fp8;
- (id)sendMMSFromData:(id)fp8 messageId:(unsigned int)fp12;
- (id)sendMMS:(id)fp8;
- (id)send:(id)fp8;
- (id)incomingMessageWithId:(unsigned int)fp8 telephonyCenter:(struct __CTTelephonyCenter *)fp12 isDeferred:(BOOL)fp16;
- (int)incomingMessageCount;
- (id)allIncomingMessages;
- (void)acknowledgeIncomingMessageWithId:(unsigned int)fp8;
- (void)acknowledgeOutgoingMessageWithId:(unsigned int)fp8;
- (id)incomingMessageWithId:(unsigned int)fp8;
- (id)deferredMessageWithId:(unsigned int)fp8;
- (id)statusOfOutgoingMessages;
- (id)encodeMessage:(id)fp8;
- (id)decodeMessage:(id)fp8;
- (BOOL)isMmsEnabled;
- (BOOL)isMmsConfigured;
- (BOOL)sendSMSWithText:(id)fp8 serviceCenter:(id)fp12 toAddress:(id)fp16;

@end

示例:

#import "CTMessageCenter.h"

BOOL success = [[CTMessageCenter sharedMessageCenter]  sendSMSWithText:@"test" serviceCenter:serviceCenterNumberAsString toAddress:numberAsString];

【讨论】:

  • 原发帖者提到他是个人使用的应用,不打算提交到应用商店。话虽如此,您的回答对于回答他的问题并不是很有建设性。
  • @brandonbocklund 你读过答案吗?这是一种未经批准的方式。我的问题是越狱方式,这正是他所要求的。
  • @fbernardo 感谢您的快速回复。只需要被开发人员程序接受,这样我就可以在手机上进行测试。会回来报告的。
  • 它没有用。好吧,它确实确实发送了短信,但完全忽略了 serviceCenter 参数。必须使用不同的 Numberformats 进一步尝试,可能国际格式有问题(以 +41 开头)
  • 不,似乎 serviceCenter 参数被完全忽略了。所以我仍在寻找以编程方式更改 SMSC 的解决方案...
【解决方案2】:

您需要使用 AT 命令更新 SIM 卡上的 SMSC。

在 iOS 上,您可以使用私有框架 SKTelephonyController。

获取 SIM 卡上当前 SMSC 的 AT 命令: AT+CSCA?

写入 SIM 卡: AT+CSCA = "1xxxxxxxxxx",145

【讨论】:

  • Nexus2k 表示私有框架 API 不起作用。所以我只是提供另一种解决方案。
猜你喜欢
  • 2011-09-08
  • 1970-01-01
  • 1970-01-01
  • 2018-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多