Making phone calls programmatically - iphone

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]]

Related

Open itune link in app store?

My application is in 3 languages, i want to open app store on button click and link is my another application. But when i am sending link to app store , its always opening US market with English description. when i am using browser its going correct. Where i am going wrong.
-(IBAction)Button_us_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/us/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
-(IBAction)Button_fr_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/fr/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
-(IBAction)Button_du_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/de/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
It is might be because you are using/Logged in US store.
Actually it's pretty easy. You have two mistakes:
You are using country code in the links. i.e. you are mention exactly what store you want to open. This is bad because on some cases the user would open different store than the one you need. If you ask for US and user registered for another one you would lose him.
You probably can't tell which store the user is register to. So even if you create the the right link you can never tell which function to call (there is no API to know where the user is registered according to my knowledge - you can just know where he is or his language settings).
So, You could just remove the country code. i.e:
NSString *ituneLink =#"https://itunes.apple.com/app/My_application/AppID?mt=8&ign-mpt=uo%3D4"
But even then you would probably have problems with the link itself on some cases and in some OS versions.
I suggest you use a simple library called iLink that would figure out everything (at run time) and create the link you need that would work always. It also have a great feature that would prompt the user for an update if there is one on the store.
You are giving denmark app link. And I think you are logged in with other country.

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.

Make an autocall programmatically in iOS

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.

Rate my Application in iTunes within my Application in iPhone

I have to provide a link in my app where the user touches on it it will take me to the itunes Appstore page of my application where the user can rate the Application. I think other apps try to access the Appstore Application in the device and pass the corresponding url of the application in itunes... How to do this? Any ideas...
Here's my method; this goes straight to the App Store and to the Review/Rate page for my app:
- (IBAction)rateGame {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=409954448"]];
}
Just change the id at the end (409954448) to the id for your app. Also, if you track the launch count or something, you can trigger this method after, say 12 launches to increase ratings. I added this in my update and in about 2 weeks it generated 5 ratings. Very useful.
NSURL* urlToMyApp = #"http://url.to.my/app/in/the/app/store";
[[UIApplication sharedApplication] openURL:urlToMyApp];
You can also use,
See link below, It will redirect you on app store app details page.
StoreKit.framework not needed.
http://www.brianjcoleman.com/tutorial-how-to-add-write-a-review-rate-us-feature-to-your-app/
Notes :
If iOS >= 7 use, [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:#"itms-apps://itunes.apple.com/app/idYOUR_APP_ID"]]];
This will not work on simulator so don't test on Simulator :-)

Use of setApplicationBadgeString on iPhone SDK

I am developing a piece of code which where I would like to dynamically update the badge of the application, so show its status. Pretty regular.
I am using this following API
[[UIApplication sharedApplication] setApplicationBadgeString:#"x"];
My problem is that when I try to use this API multiple times within an application session, the badge which is displayed on the Springboard does not get updated.
My use is
//Check if user is logged in then
[[UIApplication sharedApplication] setApplicationBadgeString:#"On"];
//wait for network event
[[UIApplication sharedApplication] setApplicationBadgeString:#"Off"];
Any help will be much appreciated.
Nitin
What you're describing works perfectly on my end.
This is an undocumented API, so I can't confirm, but perhaps it needs to be executed on the main thread, not a background one.
Also, be advised that because this is a private API, its use is grounds for rejection from the AppStore.