Make an autocall programmatically in iOS - iphone

Is it possible to do a call to a predefinite number in iphone sdk with some system api?

You can do this as follows, but the user will need to accept the call placement.
NSURL *telephoneURL = [NSURL URLWithString:#"tel:01234567890"];
[[UIApplication sharedApplication] openURL:telephoneURL];
If you're attempting to place a call without the user's acknowledgement, then this (thankfully) isn't possible using the public API.

Related

Not Able to launch Google Maps App from inside another app

I am trying to open Google Maps App from inside an iOS App.
I am using this code:
[[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
but its not working. Can anyone tell me whats the issue?
First of all canOpenURL won't open an app. It just checks that the app can open the app or not. Use openURL method instead.
if([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]])
{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:#"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
}
Note:
For opening a third party app using the URL Scheme. It should be installed on the device.
canOpenURL:
Returns whether an application can open a given URL resource.
- (BOOL)canOpenURL:(NSURL *)url
Parameters
url
A URL object that identifies a given resource. The URL’s scheme—possibly a custom scheme—identifies which application can
handle the URL.
Return Value
NO if no application is available that will accept the URL; otherwise,
returns YES.
Discussion
This method guarantees that that if openURL: is called, another
application will be launched to handle it. It does not guarantee that
the full URL is valid.
openURL:
Opens the resource at the specified URL.
- (BOOL)openURL:(NSURL *)url
Parameters
url
An object representing a URL (Universal Resource Locator). UIKit supports the http:, https:, tel:, and mailto: schemes.
Return Value
YES if the resource located by the URL was successfully opened;
otherwise NO.
Discussion
The URL can locate a resource in the same or other application. If the
resource is another application, invoking this method may cause the
calling application to quit so the other one can be launched.
You may call canOpenURL: before calling this one to verify that there
is an application that can handle it.
Please refer UIApplication Class.

iPhone dev - How can I call a phone number from within an app? Also, how can I hang-up from within the app?

Those are the two basic questions. First of all, I need to know if it's even possible to programmatically hang-up the phone from within my app (when the user presses a button, for instance). Also, is it possible to make a call from within my app, without having to leave my app? As in, the user can talk on the phone, but still see my app front and center the whole time?
Thanks
No to both questions*: it's not possible, unless you go to the dark side (jailbreak).
To know what kind of options are available to developers in regard to the phone functionality, take a look at Core Telephony's documentation.
You can pass a phone call by passing a url of the type tel://%# to [[UIApplication sharedApplication] openURL:url] but you can't "stay" in the App itself (phone.app will take care of the phone call).
When you programmatically make a phone call, your app jumps into the phone app.
You can make a phone call like this:
NSURL *url = [[[NSURL alloc] initWithString:[NSString stringWithFormat:#"tel://%#", kSavedNumber]] autorelease];
[[UIApplication sharedApplication] openURL:url]
Once you do this, the user will not be in your app, and they will be hanging up using the standard phone interface.

Making phone calls programmatically

How can we make phone calls programmatically without using the code
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://9423456789"]];
The method you've suggested is the only means of programmatically requesting that a call is placed.
If you're attempting to subvert the user's acceptance of the call, then this isn't possible using the public APIs.
So do this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://9423456789"]];
Then create a local notification that pops up in 1 seconds to bring the user back to your app.
The only way to make a call completely within your own application is to create your own VoIP-like solution. You can't make cellular phone calls within your own app.
It's completely user-controllable and, just like sending SMS and email, should stay that way. There were too many applications for Windows Mobile for example, which would send premium SMS behind user's back.
#Prasanth T R
But the my app is switching to the Phone app and it's cannot turn back
to my app after ending the call. I need the call to be made within my
app
To go back to your app, use telprompt://9423456789 instead of tel://9423456789
using "telprompt://" when a call finish the user will go back to your app
NSString *phoneDigits = #"9423456789";
NSString *phoneNumber = [NSString stringWithFormat#"telprompt://%#",phoneDigits];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]]

Direct "rate in iTunes" link in my app?

I've seen posts here on Stackoverflow that describe how to allow users to be directed to apps on the app store.
Is there a way to link directly to the rating and comments form in the App Store?
This IS possible using the technique described on this blog:
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
basically you call UIApplication openURL with the following:
NSString* url = [NSString stringWithFormat: #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%#", myAppID];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
To get your app ID before your app is available in the app store, use iTunesConnect to define your new app - give it a name, description, icon, screenshots, etc. Once defined, you can get the Apple ID from the Identifiers section for the app.
EDIT:
Here is a secondary url/method that works:
NSString* url = [NSString stringWithFormat: #"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%#&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", appid];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url ]];
I believe the difference between the two is that the first technique (itms-apps://) will launch the App Store app directly while the second one (http://) will launch it indirectly via a redirect resulting from the http web URL. This would have to be confirmed; this is only my recollection.
Answers here are outdated.
This works on my end (Xcode 5 - iOS 7 - works only on Device, not simulator!):
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
For versions lower than iOS 7 use the old one:
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID
Simple method that I am using is;
-(void)rateApp {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[#"itms-apps://itunes.apple.com/app/" stringByAppendingString: #"id547101139"]]]; }
You can also use SKStoreProductViewController as an alternative. It will open the store in your app. You may like it better than opening another app, especially on iPads.
Thanks to Ahment swift version:
UIApplication.sharedApplication().openURL(NSURL(string: "itms-apps://itunes.apple.com/app/id951334398")!)

Querying the Installed URL Handlers on iPhone

Is there some why my application can query the URL handlers that have been installed / are supported?
The use case here is that I'd like my app to allow users to send tweets using either its built in tweeting, or by using their preferred twitter client. I'd like to let them select the client from a list of those that they have on the phone (or show a list with those they have installed highlighted, or something). Another app I plan to write would also benefit from being able to check for available handlers to then provide integration possibilities to its user.
Thanks,
Benjohn
You can only find if there is a handler for a given URL via UIApplication.canOpenURL::
NSURL *url = [NSURL urlWithString:#"http://example.com"];
BOOL tweet = [[UIApplication sharedApplication] canOpenURL:url];
Unfortunately, you cannot query for all the handlers or know which application handles which urls.