I have to solve the following problem in objective-c:
Application in background
For an event, i need to call a specific phone number on the iPhone while it is still in background
As i see my logs, the phone call method will be called, but the phone number not dialing by the iOS.
Here is the action method:
//------------------------------------------------//
- (IBAction)actionCall:(id)sender
{
id<ICallModel> _AutoCall = [self retrieveAutoCall];
if(_AutoCall != nil)
{
DDLogDebug(#"RESCUE CALL: %#",_AutoCall.PhoneNumber);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",_AutoCall.PhoneNumber]]];
}
[self actionCancel:nil];
}
//------------------------------------------------//
If the application is active, then it works perfectly.
I've added the proper background modes too.
Is it possible some way to achieve this flow?
Thanks,
Tom
Apple doesn't allow you to start calls if your app is running in the background.
What you could do is using Local Notifications to make the user returning to your app.
Once your app is back in the foreground it could start the call.
Related
I'm planning to create an iOS VoIP app(not made any iOS app before). I was reading about Callkit in IOS by which one can make his app receive phone call through iPhone native call screen.
I read Callkit api here where it is mentioned that one can know if a call is answered.
Going through this tutorial and here is the code which detects the call is answered:
-(void)reportIncomingCallWithHandle:(NSString *)handle
success:(void (^)())success
failure:(void (^)(NSError * error))failure {
CXCallUpdate *update = [self newCallUpdateWithHandle:handle];
self.callId = [NSUUID UUID];
[self.provider reportNewIncomingCallWithUUID:self.callId update:update completion:^(NSError * _Nullable error) {
if (error) {
if (failure) failure(error);
} else {
if (success) {
success();
}
}
}];
}
See the success block. So is there is a way to open my app when this success block executed? Or can I override default buttons on caller screen to open my app?
I know there is no way to open an app on receiving any kind of notification, or event trigger. So thought may be there is some way if I can do the same using Callkit
I Googled everything but found no clue regarding my above queries. Please help me if it is possible or not.
I encountered the same issue. The behavior varies depending on if the device is locked or not.
Locked: System calling screen appears. You can run the app in the background including view transitions. However, the user will only see the system calling screen although your app is kind of presented underneath the view. As the device is locked, deep links does not work as well.
Unlocked: Calling screen is the same but once the user answers the call, the app will be presented.
As you may know, we can change the icon of the button on the calling screen which opens the app, and that's the best we can do as of now.
You can not open your own VoIP app or custom UI of your App from CallKit. Use can use it in a way as Whatsapp does.
Means you can awake your app from background without using local notification. And OS will show the default incoming screen. You need not to handle anything during call. CallKit is specially made for enhancing VoIP apps by receiving calls in background, by making outgoing calls, by managing Call directory and blocking of users.
On a button click I am making a call inside my app by using the following code
NSString *phoneNumber =#"telprompt://123-4567-890";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
I want to do some working if the call is failed or disconnected (might be due to low balance or network signal problem). Is there any delegate for call disconnect or failure for doing this? Any help will be appreciated.
No, once you have handed over functionality to the telephone app your app is then put in the background and will only be activated once the user goes back to it manually.
When my iOS app makes a phone call by doing the following:
NSString *telephoneUrl = #"tel:12345678";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneUrl]];
what happens to the app lifecycle state?
e.g. if I put the following lines below the above phone call lines:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(#"dispatch callback was called!!!");
});
On iOS 7, applicationDidEnterBackground is called, the above code doesn't run, and when the phone call terminates, I am inside the Phone app. The console lines are written only when i return to my app.
However, on iOS 8, only applicationWillResignActive is called and the app doesn't enter background, and you can actually see the log being written to the console while I am inside the phone call. When the call terminates, i am still inside my app.
Can someone confirm the behaviour, or point me to the relevant documentation?
Yes iOS 7 & iOS 8 are different here. And I can't find document about it either.
So in iOS 7 if you have an incoming call applicationWillResignActive: will be called first. If you reject the phone applicationDidEnterBackground will not be called;but if you answer the phone applicationDidEnterBackground will be called and when you end the phone and your app become active again applicationWillEnterForeground: will be called too.
But in iOS 8 only applicationWillResignActive: will be called no matter you answer the phone or not.
I want the user to be able to call a phone number form within my app. Is it possible for the user to be returned straight back to the application after finishing the call?
1: I guess that this is the default behavior, isn't it?
2: you can check if the device can open the tel:// protocol:
BOOL canCall = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tel://"]];
I know this is an old question but this can be done using:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://111222333"]];
I believe this can be done for iOS >= 5.0.
The behaviour of telprompt:// is slightly different than tel://.
1
It depends how you initiate the call.
You can chose between:
Present a pop-up in which the user has to approve the call. Your app will be launched afterwards again.
Directly call, without showing a pop-up first. Your app wont be launched after the call.
for how to implement both ways, please read this question: iOS 4.2 - Return to app after phone call
2
Check if the device can open tel: URLs with the following code:
BOOL isPhone = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tel:123456789"]];
I need to do a call in background to a number and, if is possible, to enter a code during the call. Can I do this?
This call must be done via user's phone!
in background? No. You can always use
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:#"tel:1234567890"]];
to make a call, but it will open the Phone app