[英]Get SMS broadcast with text body without Jailbreak BUT private frameworks in IOS
我想知道在輸入文本時是否可以發送SMS廣播。我還想檢索整個正文和發件人信息。 我想知道是否可以僅通過私有框架而不越獄。 我不會出售該應用程序,僅用於我的個人電話,但我正試圖避免越獄的貓和老鼠。
這是我的方法。 無需越獄,只需私有API。
CoreTelephony框架:
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框架:
int IMDMessageRecordGetMessagesSequenceNumber();
私有ChatKit框架: CKDBMessage
可以在這里找到
CTTelephonyCenterAddObserver(CTTelephonyCenterGetDefault(),
NULL,
TelephonyObserver,
kCTMessageReceivedNotification,
NULL,
CFNotificationSuspensionBehaviorHold);
從iOS 8開始,您不能為通知名稱參數傳遞NULL
來接收所有電話通知。 您必須告訴它要觀察者的通知,就像達爾文通知中心一樣。
void TelephonyObserver(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
if ([(__bridge NSString*)name isEqualToString:(__bridge NSString*)kCTMessageReceivedNotification])
{
SmsReceived();
}
}
void SmsReceived()
{
int lastID = IMDMessageRecordGetMessagesSequenceNumber();
CKDBMessage* msg = [[CKDBMessage alloc] initWithRecordID:lastID];
}
我們在這里做什么。 收到接收到SMS的通知后,我們將獲得SMS數據庫中的最后一行ID( lastID
)。 然后使用該ID創建消息對象。 msg
將包含所有消息內容。
使用CKDBMessage
和initWithRecordID:
您可以訪問任何SMS數據庫記錄。 如果未找到行ID,則initWithRecordID:
將返回nil。
適用於iOS 7.x-9.1。 僅對SMS消息進行了測試,但也應與MMS一起使用。 注釋中的用戶已在iMessages上成功測試。
iOS 8.3更新
從iOS 8.3開始,如果沒有越獄,您將無法接收kCTMessageReceivedNotification
通知。 您需要授權
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>spi</string>
</array>
iOS 11更新
從iOS 11開始,您不能使用CKDBMessage
。 蘋果公司向沙盒添加了另一條規則,可能要求該應用程序具有特定的權利進行簽名才能使用該API。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.