- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我知道这在实际应用中是不允许的,这有利于用户的隐私和安全。但出于纯粹的学术目的,我试图在不显示 MessageComposer UI 的情况下发送消息。
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]) {
picker.recipients = [NSArray arrayWithObject:@"1234"];
picker.body = @"Hello";
[picker performSelector:@selector(smsComposeControllerSendStarted:) withObject:[UIButton buttonWithType:UIButtonTypeCustom]];
}
uint varCount = 0;
Class cls= [MFMessageComposeViewController class];
Ivar *vars = class_copyIvarList(cls, &varCount);
for (uint i = 0; i < varCount; i++) {
Ivar var = vars[i];
const char* name = ivar_getName(var);
const char* typeEncoding = ivar_getTypeEncoding(var);
printf("iVar%i------------> %s\n",i+1,name);
}
free(vars);
Method *imps = class_copyMethodList(cls, &varCount);
for (uint i = 0; i < varCount; i++) {
SEL sel = method_getName(imps[i]);
printf("Method%i------------> %s\n",i+1,[(NSStringFromSelector(sel)) UTF8String]);
}
iVar1------------> _messageComposeDelegate
iVar2------------> _recipients
iVar3------------> _body
iVar4------------> _subject
iVar5------------> _mutableAttachmentURLs
iVar6------------> _currentAttachedVideoCount
iVar7------------> _currentAttachedAudioCount
iVar8------------> _currentAttachedImageCount
iVar9------------> _temporaryAttachmentURLs
iVar10------------> _attachments
Method1------------> disableUserAttachments
Method2------------> setCurrentAttachedVideoCount:
Method3------------> setCurrentAttachedAudioCount:
Method4------------> setCurrentAttachedImageCount:
Method5------------> _MIMETypeForURL:
Method6------------> _isVideoMIMEType:
Method7------------> _isAudioMIMEType:
Method8------------> _isImageMIMEType:
Method9------------> mutableAttachmentURLs
Method10------------> _contentTypeForMIMEType:
Method11------------> _updateAttachmentCountForAttachmentURL:
Method12------------> _buildAttachmentInfoForAttachmentURL:andAlternameFilename:
Method13------------> temporaryAttachmentURLs
Method14------------> canAddAttachmentURL:
Method15------------> addAttachmentData:withAlternateFilename:
Method16------------> _setCanEditRecipients:
Method17------------> messageComposeDelegate
Method18------------> setMutableAttachmentURLs:
Method19------------> currentAttachedVideoCount
Method20------------> currentAttachedAudioCount
Method21------------> currentAttachedImageCount
Method22------------> setTemporaryAttachmentURLs:
Method23------------> dealloc
Method24------------> viewWillAppear:
Method25------------> initWithNibName:bundle:
Method26------------> automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
Method27------------> setModalPresentationStyle:
Method28------------> body
Method29------------> setSubject:
Method30------------> subject
Method31------------> setMessageComposeDelegate:
Method32------------> setBody:
Method33------------> addAttachmentURL:withAlternateFilename:
Method34------------> addAttachmentData:typeIdentifier:filename:
Method35------------> attachmentURLs
Method36------------> attachments
Method37------------> recipients
Method38------------> smsComposeControllerCancelled:
Method39------------> smsComposeControllerSendStarted:
Method40------------> setRecipients:
smsComposeControllerSendStarted:
方法可能更像是一个委托(delegate),而不是启动消息发送的实际函数。在上面的方法列表中,没有一个方法签名看起来更接近
sendMessage:
或类似于实际发送消息的函数的东西。
MFMessageComposeViewController
在引擎盖下。或者它是否有一些无法通过运行时函数访问的类集群?
最佳答案
内MFMessageComposeViewController
用途 CKSMSComposeController
作为私有(private)的实际 UI ChatKit.framework
它使用了一大堆其他类( CKSMSComposeQueuingRemoteViewControllerProxy
、 CKSMSComposeRemoteViewController
、 CKSMSComposeViewServiceController
),包括 XPC 接口(interface) XPCProxy<CKSMSCompose>
.
更新 1
在阅读了 quellish 评论后,我发现了这个 http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/看起来像 MFMessageComposeViewController
和类似的类为它们的目的启动另一个进程。这些进程是 XPC 服务,它们实现了某些协议(protocol),您的应用程序通过这些协议(protocol)与它们进行通信。这些流程都签署了所有必需的权利。大概 /Applications/MessagesViewService.app/MessagesViewService
是实际发送短信的内容。这个二进制文件是用 com.apple.messages.composeclient
签名的这是发送带有 this 的消息所必需的我在 ChatKit.framework 中找到的代码。我认为有一种方法可以手动与该 XPC 服务通信以发送短信,但这会很困难。不是你可以用 class-dump 和类似的简单工具来鬼混的东西,这些工具并没有真正给你很多信息。
更新 2
我已经设法弄明白了。我已经扔掉了所有的助手类,所有没有真正与 XPC 服务通信的 UI 东西。剩下的就足以显示 SMS View Controller 并向 XPC 服务发送一些方法,而不会有任何阻碍。
当我们显示短信撰写 UI 时 iOS 确实启动 /Applications/MessagesViewService.app/MessagesViewService
过程。这就是 XPC 服务。你可以在你的应用程序显示它时尝试杀死它 - 你会得到黑屏,这意味着它是正确的。CKSMSComposeRemoteViewController
是显示 SMS UI 的 View Controller 。它是 _UIRemoteViewController
的子类类(class)。基本上,它管理我们的应用程序和在其他进程中的 XPC 服务中运行的实际 UI 之间的连接。这是我如何在我的 -(void)viewDidLoad
中获取它的实例方法
_UIAsyncInvocation* cancelationInvocation =
[CKSMSComposeRemoveViewController requestViewController:@"CKSMSComposeViewServiceController"
fromServiceWithBundleIdentifier:@"com.apple.mobilesms.compose"
connectionHandler:
^(CKSMSComposeRemoteViewController* obj, NSError* error){
smsViewController = obj;
[smsViewController setDelegate:self];
smsViewControllerProxy = [smsViewController serviceViewControllerProxy];
}];
smsViewController
是一个远程 View Controller 实例。
smsViewControllerProxy
是
XPCProxy<CKSMSCompose>
实现
CKSMSComposeViewServiceProtocol
的实例协议(protocol) - 方法调用将被转发到 XPC 服务。
XPCProxy
并没有真正实现这些方法。它实现了
forwardInvocation:
方法以便将调用转发到 XPC 连接。
_UIAsyncInvocation
, 查看 ivar 名称
cancelationInvocation
, 用于取消 XPC 消息。它仅在
CKSMSComposeController viewServiceDidTerminateWithError:
中被调用方法。
[self presentViewController:smsViewController animated:YES completion:NULL];
[smsViewController setDelegate:self]
.代表必须执行
CKSMSComposeRemoteViewControllerDelegate
协议(protocol)或应用程序将因异常(无法识别的选择器)而崩溃。这是我实现的:
-(void)smsComposeControllerAppeared
{
}
-(void)smsComposeControllerCancelled
{
}
-(void)smsComposeControllerDataInserted
{
}
[smsViewControllerProxy insertTextPart:@"Some text"];
smsComposeControllerDataInserted
委托(delegate)方法。
Incoming event
这意味着它是来自服务的传入消息。
Connection name
只是 XPC 连接名称。
Message
是 XPC 消息字典内容。
Message data
- 一些 XPC 消息在 "d"->"r"键包含二进制数据。这是一个序列化的二进制属性列表,不能用
NSPropertyListSerialization
反序列化- 它是某种新格式。相反,您需要使用
NSXPCDecoder -(id)_initWithRootXPCObject:(xpc_object_t)
来自
Foundation.framework
.现在转储:
关于ios - 入侵 MFMessageComposeViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22653828/
IO 设备如何知道属于它的内存中的值在memory mapped IO 中发生了变化? ? 例如,假设内存地址 0 专用于保存 VGA 设备的背景颜色。当我们更改 memory[0] 中的值时,VGA
我目前正在开发一个使用Facebook sdk登录(通过FBLoginView)的iOS应用。 一切正常,除了那些拥有较旧版本的facebook的人。 当他们按下“使用Facebook登录”按钮时,他
假设我有: this - is an - example - with some - dashesNSRange将使用`rangeOfString:@“-”拾取“-”的第一个实例,但是如果我只想要最后
Card.io SDK提供以下详细信息: 卡号,有效期,月份,年份,CVV和邮政编码。 如何从此SDK获取国家名称。 - (void)userDidProvideCreditCardInfo:(Car
iOS 应用程序如何从网络服务下载图片并在安装过程中将它们安装到用户的 iOS 设备上?可能吗? 最佳答案 您无法控制应用在用户设备上的安装,因此无法在安装过程中下载其他数据。 只需在安装后首次启动应
我曾经开发过一款企业版 iOS 产品,我们公司曾将其出售给大型企业,供他们的员工使用。 该应用程序通过 AppStore 提供,企业用户获得了公司特定的配置文件(包含应用程序配置文件)以启用他们有权使
我正在尝试将 Card.io SDK 集成到我的 iOS 应用程序中。我想为 CardIO ui 做一个简单的本地化,如更改取消按钮标题或“在此保留信用卡”提示文本。 我在 github 上找到了这个
我正在使用 CardIOView 和 CardIOViewDelegate 类,没有可以设置为 YES 的 BOOL 来扫描 collectCardholderName。我可以看到它在 CardIOP
我有一个集成了通话工具包的 voip 应用程序。每次我从我的 voip 应用程序调用时,都会在 native 电话应用程序中创建一个新的最近通话记录。我在 voip 应用程序中也有自定义联系人(电话应
iOS 应用程序如何知道应用程序打开时屏幕上是否已经有键盘?应用程序运行后,它可以接收键盘显示/隐藏通知。但是,如果应用程序在分屏模式下作为辅助应用程序打开,而主应用程序已经显示键盘,则辅助应用程序不
我在模拟器中收到以下错误: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedIm
如 Apple 文档所示,可以通过 EAAccessory Framework 与经过认证的配件(由 Apple 认证)进行通信。但是我有点困惑,因为一些帖子告诉我它也可以通过 CoreBluetoo
尽管现在的调试器已经很不错了,但有时找出应用程序中正在发生的事情的最好方法仍然是古老的 NSLog。当您连接到计算机时,这样做很容易; Xcode 会帮助弹出日志查看器面板,然后就可以了。当您不在办公
在我的 iOS 应用程序中,我定义了一些兴趣点。其中一些有一个 Kontakt.io 信标的名称,它绑定(bind)到一个特定的 PoI(我的意思是通常贴在信标标签上的名称)。现在我想在附近发现信标,
我正在为警报提示创建一个 trigger.io 插件。尝试从警报提示返回数据。这是我的代码: // Prompt + (void)show_prompt:(ForgeTask*)task{
您好,我是 Apple iOS 的新手。我阅读并搜索了很多关于推送通知的文章,但我没有发现任何关于 APNS 从 io4 到 ios 6 的新更新的信息。任何人都可以向我提供 APNS 如何在 ios
UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题是为了让其他人轻松找到答案。 那么:在 iPhone 和 iPad 上的 iOS 8/9/10/11
我想我可以针对不同的 iOS 版本使用不同的 Storyboard。 由于 UI 的差异,我将创建下一个 Storyboard: Main_iPhone.storyboard Main_iPad.st
我正在写一些东西,我将使用设备的 iTunes 库中的一部分音轨来覆盖 2 个视频的组合,例如: AVMutableComposition* mixComposition = [[AVMutableC
我创建了一个简单的 iOS 程序,可以顺利编译并在 iPad 模拟器上运行良好。当我告诉 XCode 4 使用我连接的 iPad 设备时,无法编译相同的程序。问题似乎是当我尝试使用附加的 iPad 时
我是一名优秀的程序员,十分优秀!