0

I am working on a concept and I do not need it in the appstore. I have searched for the ways to do this. Found this one answer which says its been done in iOS 4,5,6. Please check below link.

Is there any private api for iphone that detect sms sent or received

The example code is in C,C++ and makes very little sense in terms of Objective-C. Is there any other way to detect a call/message notification from within the app? Any amount of help is appreciated.

Community
  • 1
  • 1
Obj-Swift
  • 2,802
  • 3
  • 29
  • 50

2 Answers2

2

CoreTelephony is a CoreFoundation framework, in other words it is a C/C++ API. In addition it has very little documented functionality, basically you can eventually find out that a call (not SMS) was handled. There is almost certainly additional private information available through the API, but it's not going to be widely documented. The published Apple documentation can be found here. Using any functionality outside of what's documented there is not only going to prevent you from putting the application in the store, it's quite likely to break the application in the (not too distant) future.

David Berry
  • 40,941
  • 12
  • 84
  • 95
1

Found the solutions to detect calls here. The solution in the question worked when app is in foreground. Note: the answer on the question did not work for me.

in AppDelegate.h file

@property (weak, nonatomic) CTCallCenter* callCenter; 

in AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ 
        self.callCenter = [[CTCallCenter alloc] init];
         [self.callCenter setCallEventHandler:^(CTCall *call)
      {
             NSLog(@"Event handler called");
         if ([call.callState isEqualToString: CTCallStateConnected])
         {
             NSLog(@"Connected");
         }
         else if ([call.callState isEqualToString: CTCallStateDialing])
         {
             NSLog(@"Dialing");
         }
         else if ([call.callState isEqualToString: CTCallStateDisconnected])
         {
             NSLog(@"Disconnected");

         } else if ([call.callState isEqualToString: CTCallStateIncoming])
         {
             NSLog(@"Incomming");
         }
     }];  

return YES;

}

Community
  • 1
  • 1
Obj-Swift
  • 2,802
  • 3
  • 29
  • 50