Http://stackoverflow.com/questions/19175209/sending-sms-using-ctmessagecenter-ios-7
The following code is invalid on IOS7, and after a search, the solution is as follows. The pro-test is effective.
I am trying to send SMS programmatically using private API. My phone is not jailbroken.
BOOL success= [[Ctmessagecenter Sharedmessagecenter] Sendsmswithtext:@< span class= "str" > "Test 1234 ..." Servicecenter:nil toaddress:@ "0777888888" ]; if (success nslog (@ "Message SENT" ); }else{ Nslog "Message not SENT" /span>
This code always prints "Message not SENT". Can anyone help me?
I guess, you had to write the telephone number in e.123 international notation. So add plus sign and country code. For a phone number are USA replace the leading 0 with + 1:
[[CTMessageCenter sharedMessageCenter] sendSMSWithText:@"test 1234..." serviceCenter:nil toAddress:@"+1777888888"];
For a phone number are Sri Lanka use the appropriate country code +94.
UPDATE
I ' ve tested old working iOS 5 code under iOS 7 ... sendSMSWithText:serviceCenter:toAddress:
returns NO
. The same while using the new methodsendSMSWithText:serviceCenter:toAddress:withMoreToFollow:
Panagiotis ' suggestion seems correct:-/
UPDATE 2
http://stackoverflow.com/a/20425853/2270880 gives the right answer.
Under IOS 7 The app needs-entitlements com.apple.CommCenter.Messages-send
and com.apple.coretelephony.Identity.get
. Adding additional entitlements via file appname.entitlements
(and set in target ' s Build Settings > All > Code Signing > Code Sig Ning entitlements) give you the error
The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.(0xE8008016).
On Non-jailbroken devices.
Jailbreak mobile phone Send SMS