使用文本正文进行短信广播,而不使用IOS中的Jailbreak BUT私有框架 [英] Get SMS broadcast with text body without Jailbreak BUT private frameworks in IOS
问题描述
我想知道在文本进来时是否可以收到短信广播。我还想检索整个身体和发件人信息。我想知道这是否可以通过私人框架只有没有越狱。我不会出售这个应用程序,只是为了我的个人电话,但我正在努力避免越狱的猫捉老鼠。
I would like to know if it is possible to get an SMS broadcast when a text comes in. I also want to retrieve the whole body and sender info. I want to know if this is possible through Private Frameworks only without jailbreaking. I'm not going to sell the app, it's just for my personal phone but I'm trying to avoid the jailbreak cat and mouse.
推荐答案
我是这样做的。不需要越狱,只需要私有API。
Here is how I do it. No jailbreak required, only private APIs.
CoreTelephony框架:
CoreTelephony framework:
extern CFStringRef const kCTMessageReceivedNotification;
CFNotificationCenterRef CTTelephonyCenterGetDefault();
void CTTelephonyCenterAddObserver(CFNotificationCenterRef ct, void* observer, CFNotificationCallback callBack, CFStringRef name, const void *object, CFNotificationSuspensionBehavior sb);
void CTTelephonyCenterRemoveObserver(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object);
私人IMDPersistence框架:
Private IMDPersistence framework:
int IMDMessageRecordGetMessagesSequenceNumber();
可以找到私人ChatKit框架: CKDBMessage
此处
Private ChatKit framework: CKDBMessage
can be found here
CTTelephonyCenterAddObserver(CTTelephonyCenterGetDefault(),
NULL,
TelephonyObserver,
kCTMessageReceivedNotification,
NULL,
CFNotificationSuspensionBehaviorHold);
从iOS 8开始,你无法传递 NULL
用于接收所有电话通知的通知名称参数。您必须告诉它您希望观察哪个通知,就像darwin通知中心一样。
As of iOS 8 you can't pass NULL
for notification name argument to receive all telephony notifications. You must tell it which notification you would like to observer, just like with darwin notifiction center.
void TelephonyObserver(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
if ([(__bridge NSString*)name isEqualToString:(__bridge NSString*)kCTMessageReceivedNotification])
{
SmsReceived();
}
}
阅读邮件内容
Reading message contents
void SmsReceived()
{
int lastID = IMDMessageRecordGetMessagesSequenceNumber();
CKDBMessage* msg = [[CKDBMessage alloc] initWithRecordID:lastID];
}
我们在这里做什么。在我们收到收到SMS的通知后,我们将获取SMS数据库中的最后一行ID( lastID
)。然后使用该ID创建消息对象。 msg
将包含所有消息内容。
What we are doing here. After we received notification that SMS was received we are getting the last row ID in the SMS database (lastID
). Then creating message object with that ID. msg
will contain all the message contents.
使用 CKDBMessage
和 initWithRecordID:
您可以访问任何短信数据库记录。如果找不到行ID initWithRecordID:
将返回nil。
Using CKDBMessage
and initWithRecordID:
you can access any SMS database record. If row ID is not found initWithRecordID:
will return nil.
适用于iOS 7.x - 9.1。仅在SMS消息上测试,但也应该与MMS一起使用。评论中的用户在iMessages上成功测试。
Works on iOS 7.x - 9.1. Tested only on SMS messages but should work with MMS as well. User in comments tested successfully on iMessages.
iOS 8.3 UPDATE
截至iOS 8.3你无法收到 kCTMessageReceivedNotification
没有越狱的通知。您需要权利
As of iOS 8.3 you can't receive kCTMessageReceivedNotification
notification without jailbreak. You need entitlement
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>spi</string>
</array>
iOS 11更新
从iOS 11开始,您无法使用 CKDBMessage
。 Apple在沙箱中添加了另一条规则,可能要求使用特定权利对该应用进行签名,以便能够使用该API。
As of iOS 11 you can't use CKDBMessage
. Apple added another rule to the sandbox and probably requires the app to be signed with specific entitlement to be able to use that API.
这篇关于使用文本正文进行短信广播,而不使用IOS中的Jailbreak BUT私有框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!