2012-12-01 26 views
2

任何人都沒有在iOS6 .Earlier程序發送短信我用的是核心電話方式發送SMS.It的優良工作到iOS5iOS6我的代碼不能正常工作。 我使用以下代碼:短信不MFMessgeViewController在iOS 6發送

BOOL成功= [[CTMessageCenter sharedMessageCenter] sendSMSWithText:@「Message」serviceCenter:nil toAddress:@「8800781656」];

我在做什麼錯?

在此先感謝

+0

如何導入CTMessageCenter頭文件。 – Anupama

回答

0

我會做出一個有根據的猜測,蘋果已經封閉了API的循環漏洞。他們不希望應用程序在沒有用戶知識的情況下在後臺發送SMS消息。在某些移動網絡上,每條短信都會花錢。

+0

這沒關係,但黑色,但我已經開發的應用程序,我只是卡在ios 6 only.Please建議或提供代碼,如果有可能的話。 –

+0

同意@Black Frog。不知道你的業務邏輯,但如果你可以使用第三方短信服務(通常花費你的錢)),這只是一個調用第三方的API(通常是一個Web API,意味着一個HTTP請求) –

0
// in .m file 
-(void)textClicked 

{ 


controller = [[MFMessageComposeViewController alloc] init]; 

if([MFMessageComposeViewController canSendText]) 

    { 


     controller.body = @"Whatever you want"; 

    controller.recipients = [NSArray arrayWithObjects:@"", nil]; 

     controller.messageComposeDelegate = self; 

     [self presentViewController:controller animated:YES completion:nil]; 
     } 


    } 

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result 

    { 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Unknown Error" 
               delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 

switch (result) { 
    case MessageComposeResultCancelled: 
     NSLog(@"Cancelled"); 
     [alert show]; 
     break; 
    case MessageComposeResultFailed: 
     [alert show]; 

     break; 
    case MessageComposeResultSent: 

     break; 
    default: 
     break; 
    } 

[self dismissViewControllerAnimated:YES completion:nil]; 
    } 



// in .h file 

import MessageUI/MessageUI.h 
and delegate for Sending Message is MFMessageComposeViewControllerDelegate 

希望這會幫助你。

+0

我不dont想要使用消息視圖controller.I想發送背景的應用程序的短信。 –

+0

在後臺發送短信已被Apple限制。如果你想通過你的應用發送短信,這是做到這一點的唯一方法。 –

+0

必須有一些做法 - 越獄iOS設備的biteSMS應用程序在iOS 6中發送SMS(和iMessages)...這只是一個計算/詢問如何執行發送的問題。 – ParrotMac