2012-01-19 61 views

回答

2

我沒有測試過這個用不上,但看at the code posted here。如果你看httpResponseForMethod:URI:,你看他/她發送消息(似乎是硬編碼支持的iOS 5或iOS 4):

CKSMSService *smsService = [CKSMSService sharedSMSService]; 

//id ct = CTTelephonyCenterGetDefault(); 
CKConversationList *conversationList = nil; 

NSString *value =[[UIDevice currentDevice] systemVersion];   
if([value hasPrefix:@"5"]) 
{ 
    //CKMadridService *madridService = [CKMadridService sharedMadridService]; 
    //NSString *foo = [madridService _temporaryFileURLforGUID:@"A5F70DCD-F145-4D02-B308-B7EA6C248BB2"]; 

    NSLog(@"Sending SMS"); 
    conversationList = [CKConversationList sharedConversationList]; 
    CKSMSEntity *ckEntity = [smsService copyEntityForAddressString:Phone]; 
    CKConversation *conversation = [conversationList conversationForRecipients:[NSArray arrayWithObject:ckEntity] create:TRUE service:smsService]; 
    NSString *groupID = [conversation groupID];   
    CKSMSMessage *ckMsg = [smsService _newSMSMessageWithText:msg forConversation:conversation]; 
    [smsService sendMessage:ckMsg]; 
    [ckMsg release];  
} else { 
    //4.0 
    id ct = CTTelephonyCenterGetDefault(); 
    void* address = CKSMSAddressCreateWithString(pid); 

    int group = [grp intValue];   

    if (group <= 0) { 
     group = CKSMSRecordCreateGroupWithMembers([NSArray arrayWithObject:address]);  
    } 

    void *msg_to_send = _CKSMSRecordCreateWithGroupAndAssociation(NULL, address, msg, group, 0);  
    CKSMSRecordSend(ct, msg_to_send); 

} 

該代碼使用正常的短信,但你可以看到以下已註釋掉的代碼:

//CKMadridService *madridService = [CKMadridService sharedMadridService]; 

「馬德里」服務可能是什麼可以發送iMessages。 See the private header here

SMS和iMessage私有API都位於ChatKit.framework中。

+0

這隻適用於監獄 – iosMentalist

+0

@Enkidu,如果你看問題標籤,你會發現這是一個越獄問題。 – Nate

+0

我不是問我通知。我添加了越獄標籤:) – iosMentalist

-4

通過非越獄iPhone也絕對到的iMessage CoreTelephony API

+0

但是越獄手機怎麼樣? –

+0

對不起,您需要Google for。我對越獄手機沒有經驗。 – aldridmc