Making call to number mentioned in the text field - iphone

I am doing a birthday Remainder application . In that i provided a textfield to enter a mobile /phone number. And bottom i provided a button in which if we press that button call need to be proceed to the number given in the text field.I tried but i am not able to do that.Can any one help me in coding.Thanks!

try this
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#",self._phoneNumber]];
[[UIApplication sharedApplication] openURL:url];
works only in iphone, must be implemented your own alert delegate methods.

Try This One.
-(void) makeCall{
NSString* phoneNumber=yourTextFiled.text;//TextFiled
NSString *phoneNumber = [NSString stringWithFormat:#"%#",phoneNumber];
NSURL* callUrl=[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",phoneNumber];
//check Call Function available only in iphone
if([[UIApplication sharedApplication] canOpenURL:callUrl]){
[[UIApplication sharedApplication] openURL:callUrl]];
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"ALERT" message:#"This function is only available on the iPhone" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
I hope,it'll Really helpful to you.

Pls check this 2 link:
calling number:
Programmatically Dial a Phone number and pass DTMF using the iPhone SDK
and why not getting value from textfield:
iPhone SDK: how to get the value of a UITextField in an alert?

Related

iOS Alarm features in my app

I am working on iOS application where I need to develop following Alarm standard features.
Set custom tone (or mute)
Set vibration (Yes/No)
Set snooze (Yes/No and snooze duration)
I have done research and found nothing helpful, first of all i want to know it is really possible? is there any restriction on these features from iOS? If it is possible please guide me so that I can explore.
Thanx in advance.
It is possible to do. You will have to post a LocalNotification for it. Have a look at this post.
To create vibration you can use AudioToolBox.framework.
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
// Yes it is possible ,for alarm you have to use UILocalNotification class
For example :
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
//---set the notification to go off in 10 seconds time---
localNotification.fireDate =[[NSDate alloc] initWithTimeIntervalSinceNow:10];
//---the message to display for the alert---
localNotification.alertBody = message.text; localNotification.applicationIconBadgeNumber = 1;
//---uses the default sound---
localNotification.soundName = UILocalNotificationDefaultSoundName; //---title for the button to display---
localNotification.alertAction = #”View Details”;
//---schedule the notification---
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
//---display the notification now---
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
- (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#”Inside
application:didReceiveLocalNotification:”
message:notification.alertBody
delegate:self cancelButtonTitle:#”OK” otherButtonTitles:nil];
[alert show];
[alert release]; }
//application:didReceiveLocalNotification: method is also called when the
application is running and the local notification is fired.

Twitter login with compatibility of ios5.0,5.1,6.0

As twitter framework is added in ios5.0 I am using its class TWTweetComposeViewController
if([TWTweetComposeViewController canSendTweet])
{
NSLog(#"can send tweet");
}
else{
NSString *message = #"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device.";
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Oops" message:message delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil];
[alertView show];
}
On this step I need to show user the login page of twitter.For that I am confused if i should redirect user to settings to login to user?
And if yes this code is not working
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
Also I have read some where that this will not work in ios6. So what should i do to just make user login for a moment and not send tweet directly. Right now i just want to make user login.
I also refer to this question It is working with ios6 well but in that case how do i handle for ios5.1 ?
Any help will be appreciated....
I figured it out with below conditional coding..
I got only this way. If anyone have any other way please suggest me.
if (SYSTEM_VERSION_LESS_THAN(#"6.0")) {
if(SYSTEM_VERSION_EQUAL_TO(#"5.0"))
{
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
}else{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"No_Tw", nil) message:NSLocalizedString(#"No_TW_Ac", nil) delegate:nil cancelButtonTitle:NSLocalizedString(#"Button_Ok", nil) otherButtonTitles:nil, nil];
[alertView show];
}
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"6.0")) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.view.hidden=TRUE;
[self presentViewController:tweetSheet animated:NO completion:^{
[tweetSheet.view endEditing:YES];
}];
}
If iOS is 5.0 then it will redirect to login of Twitter otherwise it will show alert to user to go to settings and do login. And for for iOS 6.0 and larger SLComposeViewController is working fine.

How to handle APNS Message by clicking "View" button when the app is not in active?

Am new to use APNS in iPhone app. I have used and received the message in all scenarios. When the user clicks the "View" button from the APNS alert i should do the actions in the app and navigate the user to 3rd tab.
But when the app is in In Active (The app not in use) i can't trigger the actions in the app. I have used the below code in "didFinishLaunch" but not used.
NSString *params=[[launchOptions objectForKey:#"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:#"aps"];
NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(#"remoteNotif : %#", remoteNotif);
if ([params length] > 0 )
{
UIAlertView *messageReceivedAlert = [[UIAlertView alloc] initWithTitle:#"My APP" message:#"New Message Recevied From APNS in IN-Active Stage" delegate:self cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[messageReceivedAlert show];
[messageReceivedAlert release];
}
It always returns (null).
Can anyone please help me to do this? Thanks in advance.
Use this :
- (void) application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
And you can check for inactive by using
if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive)

Twitter integration no response in (ios 5)

I am developing a application in which I have integrated Twitter by using these Twitter-Oath-iPhone.
These library are working fine on lower version then ios 5 how can I use the twitter in ios 5. I don't know either Twitter change in there API or apple have make any change in ios 5.
you used API well work in IOS 5 only minor change in "SA_OAuthTwitterEngine.m" class
Replace this Function in "SA_OAuthTwitterEngine.m" class
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate
{
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"https://twitter.com/oauth/authorize"];
}
return self;
}
Try by replace this Function in "SA_OAuthTwitterEngine.m"
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"http://twitter.com/oauth/authorize"];
}
return self;
}
in place of this code use this one
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/authorize"];
}
return self;
}
this one slove my problem........
Twitter integration for iOS 5 Tutorial:
One of the exciting new features in iOS 5 is Twitter integration. Photos, YouTube, Safari, and Maps come fully integrated. With most iOS 5 users jumping on the Twitter bandwagon (Twitter daily signups tripled, according to Twitter’s CEO), allowing your users to tweet about your app could help put it in front of more people. In this iDevBlogADay post, I want to write a tutorial for integrating your app with Twitter.
For twitter integration in ios 5 its very easy , because of new framework added in ios 5 onwards just follow there steps:
1. add twitter.framework
2. follow from twitter official site
There is a very easy way in ios-5 for twitter integration, just add Twitter framework and use this code. Link is below.
http://bit.ly/FLTwitter
you can also use this code with inbuilt framework of Twiiter in iOS5.....
just add Twitter.framework from your build library
and then just import bellow header file in your viewcontroller.h file
#import <Twitter/TWTweetComposeViewController.h>
afetr that when you want to share your message on twitter just use bellow code
in viewcontroller.m file again just import
#import <Twitter/TWTweetComposeViewController.h>
.....
- (IBAction)shareOnTwitter:(id)sender {
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:#"It's really that simple!"];
[twitter addImage:[UIImage imageNamed:#"yourimage.jpg"]];//if required
[twitter addURL:[NSURL URLWithString:#"your url link"]];//if required
[self presentViewController:twitter animated:YES completion:nil];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
if(res == TWTweetComposeViewControllerResultDone)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:#"Succes!" message:#"Your Tweet was posted succesfully" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}else if(res == TWTweetComposeViewControllerResultCancelled)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:#"Canceled" message:#"Your Tweet was not posted" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
[self dismissModalViewControllerAnimated:YES];
};
}
May this Help you
and this code is may b not work in simulator sometime so test it in device.....

Getting Facebook ID number with API

I know - I have read the documentation - but frankly Facebook is horrible at it. I can't figure out how to send a request that illicits a response. Here's what I'm trying:
NSURL *fbID = [NSURL URLWithString:#"https://graph.facebook.com/me?fields=id"];
fbUserID = [[NSData alloc] initWithContentsOfURL: fbID];
Where should this code go? Is there a specific class it is looking for if I have set 'self' as delegate?
How are you trying to integrate FB into your app? I have been looking into Facebook connect recently and found their documentation very helpful (http://developers.facebook.com/docs/guides/mobile/#ios). I know you said you looked at the documentation, but for me after going through their steps for iOS I was able to make an app that allowed users to sign in and give me access to their basic information, including ID. After going through authorization, I had the following code in my app delegate:
- (void) fbDidLogin {
//get information about the currently logged in user
[facebook requestWithGraphPath:#"me" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
NSString *name = [result objectForKey:#"name"];
NSString *msg = [[NSString alloc] initWithFormat:#"To prove this works, your name is %#",name];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Thanks for Logging In!"
message:msg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
This gets the user's full name after logging in and displays it. You can do the same thing for getting their ID.