Hooks for phone call state iOS - ios

I am looking for something similar to what is TrueCaller doing for android Don't know how it works in iOS, is it same way ?
Basically what is need is
A hook method to get call when call state changes.
And should be able to get the details in hook like phone number etc.
And make call to service with phone number for displaying name (unknown in case of no user found in our service) of who is calling in the screen.

Core Telephony does not allow you to retrieve any other information that the connection state.
So you CAN NOT get the phone number that is calling you, this has to do with privacy.
The CTCall Class only has two properties:
callID which is jus a unique id for this call, but not the phone number.
callState which is the state of the call, which is CTCallStateDialing, CTCallStateIncoming, CTCallStateConnected or CTCallStateDisconnected.

Related

Get caller number from app when it is in background or in open state in iOS 10 or below?

I am looking for some source code for iOS 10 and below by which I can get the caller number when some phone call arrived and that call can be rejected by the application, if call is some fraud call (checking the local database). 

I have followed following post but did not get any fruitful result.
Via call kit: how to get the incoming call number by using callkit

True caller app already added that feature:
https://blog.truecaller.com/2016/10/26/truecaller-now-available-on-ios-10/

I think it is possible, can anyone help me by giving some idea or source code by which that can be achieved?
It is not possible to get caller's number when user receives a call. Truecaller has a lot of conditions for it to be able to show caller's details. The truecaller app should be active. The caller should call using the truecaller app. Both the calling and call receiving devices should be connected to the internet.
So what it basically does is that when a user presses the call button on the app to call somebody, they simply send him a notification that this person is calling you. It has nothing to do with CallKit and the caller id is not displayed on the call receiving screen.

Detect Caller Name when I get Incoming call or Outgoing Call [duplicate]

I'm trying to get caller ID (phone number) at the time of incoming call.
TrueCaller has implemented this and they get the phone number of incoming caller.
I've found this information:
1. CoreTelephony Framework(It gives only calling states)
2. Apple's 9.0 update : "Maybe" contacts sync. with mail app and detects the incoming phone number.
###EDIT###
iOS 10 and above:
Use Callkit, take a look at call directory extension
According to documentation,
Identifying Incoming Callers
When a phone receives an incoming call, the system first consults the user’s contacts to find a matching phone number. If no match is found, the system then consults your app’s Call Directory extension to find a matching entry to identify the phone number. This is useful for applications that maintain a contact list for a user that’s separate from the system contacts, such as a social network, or for identifying incoming calls that may be initiated from within the app, such as for customer service support or a delivery notification.
For example, consider a user who is friends with Jane in a social networking app, but doesn’t have her phone number in her contacts. The social networking app has a Call Directory Extension, which downloads and add the phone numbers of all of the user’s friends. Because of this, when the user gets an incoming call from Jane, the system displays something like “(App Name) Caller ID: Jane Appleseed” rather than “Unknown Caller”.
To provide identifying information about incoming callers, you use the addIdentificationEntry(withNextSequentialPhoneNumber:label:) method in the implementation of beginRequest(with:).
class CustomCallDirectoryProvider: CXCallDirectoryProvider {
override func beginRequest(with context: CXCallDirectoryExtensionContext) {
let labelsKeyedByPhoneNumber: [CXCallDirectoryPhoneNumber: String] = [ … ]
for (phoneNumber, label) in labelsKeyedByPhoneNumber.sorted(by: <) {
context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
}
context.completeRequest()
}
}
Because this method is called only when the system launches the app extension and not for each individual call, you must specify call identification information all at once; you cannot, for example, make a request to a web service to find information about an incoming call.
iOS 9 and earlier:
As Kakshil mentioned, Caller ID is not possible on non jailbroken devices.
And I will give you some findings on how true caller works,
Its not reading the call history, they actually created Action
extension, wherever you try to share a contact, it will display
truecaller app extension, which coded for showing the contact
details fetched from their server
You might also get confused with push notification received for few
calls, saying
"Some X calls you". This is where truecaller used a trick. If you
noticed clearly, that push notification will be received only when
you get a call from an android user with truecaller installed. Let
me explain you in details,
X(android user with truecaller installed), calling Y(ios user with truecaller installed), the android version notify the server that X making call to Y. And server will send push notification to Y's iPhone.
Caller ID is not possible on non jailbroken devices.
However there is one way, in which you can know which user is calling, but not sure if it will be useful to you.
If you have a bluetooth device, connected to the iPhone, it will get all notifications, including incoming calls, which you can then get the caller ID for.
Apart from this, there is currently no other way at all to know the called ID.

Phone Call Recording in iOS

In phone.app (iOS Native calling app), Is there any mean by which I can perform task like
1.Identify the caller (Incoming and Outgoing), so that on the behalf of caller I can perform some task.
2.Recording of call.
3.If some audio recording already in running state then how a call record can be handled.?
In my finding a reached at below outcome
1. CTCallCenter class have the information about call but i don't get phone number.
2. Call recording is not possible as there is no Apple API to do so.There are some apps on app store but they are not capable to record the call from phone.app. I think they are recording the call by their server (3 Way call.)
3. I think it will lead towards a crash as phone call is a high priority task so that the control of mic and speaker is given to phone call.
Is there any way to get expected result ? Is it possible with call kit.?
Thanks.
Unfortunately, what you're asking for is not possible as far as I know. Your app can be aware of incoming calls and their states, but not access the phone number. Using the CallKit APIs introduced in iOS 10, you can provide a label for an incoming phone number, but even then you have to set up a predefined list of numbers and labels. Your app won't know which number called. See "Identifying Incoming Callers" in the documentation and this SO question.
As for recording calls, there are no ways to do this without introducing a third party to the call, or routing the call to a service you control.
Regards,
Martin

Get the callers phone number from an incoming call on iPhone

I'm trying to get caller ID (phone number) at the time of incoming call.
TrueCaller has implemented this and they get the phone number of incoming caller.
I've found this information:
1. CoreTelephony Framework(It gives only calling states)
2. Apple's 9.0 update : "Maybe" contacts sync. with mail app and detects the incoming phone number.
###EDIT###
iOS 10 and above:
Use Callkit, take a look at call directory extension
According to documentation,
Identifying Incoming Callers
When a phone receives an incoming call, the system first consults the user’s contacts to find a matching phone number. If no match is found, the system then consults your app’s Call Directory extension to find a matching entry to identify the phone number. This is useful for applications that maintain a contact list for a user that’s separate from the system contacts, such as a social network, or for identifying incoming calls that may be initiated from within the app, such as for customer service support or a delivery notification.
For example, consider a user who is friends with Jane in a social networking app, but doesn’t have her phone number in her contacts. The social networking app has a Call Directory Extension, which downloads and add the phone numbers of all of the user’s friends. Because of this, when the user gets an incoming call from Jane, the system displays something like “(App Name) Caller ID: Jane Appleseed” rather than “Unknown Caller”.
To provide identifying information about incoming callers, you use the addIdentificationEntry(withNextSequentialPhoneNumber:label:) method in the implementation of beginRequest(with:).
class CustomCallDirectoryProvider: CXCallDirectoryProvider {
override func beginRequest(with context: CXCallDirectoryExtensionContext) {
let labelsKeyedByPhoneNumber: [CXCallDirectoryPhoneNumber: String] = [ … ]
for (phoneNumber, label) in labelsKeyedByPhoneNumber.sorted(by: <) {
context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
}
context.completeRequest()
}
}
Because this method is called only when the system launches the app extension and not for each individual call, you must specify call identification information all at once; you cannot, for example, make a request to a web service to find information about an incoming call.
iOS 9 and earlier:
As Kakshil mentioned, Caller ID is not possible on non jailbroken devices.
And I will give you some findings on how true caller works,
Its not reading the call history, they actually created Action
extension, wherever you try to share a contact, it will display
truecaller app extension, which coded for showing the contact
details fetched from their server
You might also get confused with push notification received for few
calls, saying
"Some X calls you". This is where truecaller used a trick. If you
noticed clearly, that push notification will be received only when
you get a call from an android user with truecaller installed. Let
me explain you in details,
X(android user with truecaller installed), calling Y(ios user with truecaller installed), the android version notify the server that X making call to Y. And server will send push notification to Y's iPhone.
Caller ID is not possible on non jailbroken devices.
However there is one way, in which you can know which user is calling, but not sure if it will be useful to you.
If you have a bluetooth device, connected to the iPhone, it will get all notifications, including incoming calls, which you can then get the caller ID for.
Apart from this, there is currently no other way at all to know the called ID.

ios how to check a phone call is ended and based on that phone number i want to check in my app data base is it possible

I have tried all the ways to retrieve ongoing call. I want to trace that a phone is ended or not and after ending the phone call i want to check that phone call in database. Please tell me

Resources