problem with logging in twitter through my iphone application - iphone

i am creating a music application in which i am integrating twitter in my application
When a user clicks on particular song and then he click on the twitter tab the login page of twitter should be displayed. after entering the username and password he should be directed to the page where he can enter his comment and then post it.the problem is that when i click on twitter tab the login page is diplayed but when i enter he username and password and click on submit it does not redirect me to the page where i can post my comment. Here is my code:
(IBAction) Submit: (id) sender
{
// g=text3.text.integerValue;
u=text1.text;
p=text2.text;
int flag;
NSLog(#"Username,%d",u);
//if((u!=#"") || (p!=#""))
//if((text1.text.length >= 20 && range.length !=0) ||(text2.text.length >= 8 && range.length!=0))
if([text1.text length] != 0 || [text2.text length]!=0)
{
TwitterRequest * t = [[TwitterRequest alloc] init];
t.username =[NSString stringWithFormat: #"%#",u];
//NSString *username=[NSString stringWithFormat:#"%d",u];
t.password= [NSString stringWithFormat: #"%#",p];
//NSLog(#"Password,%d",p);
//#"ajeetyaday";
//t.username= #"ajeetyaday";
//t.password = #"gopalpur";
//NSString *name1 =[NSString stringWithFormat:#"%d",g]
//twitterMessageText.text=#" hi i am ajeet";
//[twitterMessageText resignFirstResponder];
loadingActionSheet = [[UIActionSheet alloc] initWithTitle:#"Posting To Twitter..." delegate:nil
cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[loadingActionSheet showInView:self.view];
[t statuses_update:twitterMessageText.text delegate:self requestSelector:#selector(status_updateCallback:)];
//[TwitterRequest statuses_update:twitterMessageText.text delegate:self requestSelector:#selector(status_updateCallback:)];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Clicked on Submit" message:#"Please inter Username and Password" delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles:nil];
[alert show];
[alert release];
}
}

I think u r in wrong way!!
U simply store user name and password in a global variable,and push to posting page
(IBAction) Submit: (id) sender
{
user_name=uname.text;
password=password.text;
Twitter *Controller = [[Twitter alloc] init];
[self.navigationController pushViewController:Controller animated:YES];
[Controller release];
}

Related

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.

iOS: Set tweet recipient

I know how to tweet a message using the standard iOS 5 twitter framework (using the code bellow). I do not know:
a) If it is possible to send a tweet to a specific recipient (myself). I would like to do this as a "Contact Us" feature in my app so the user can message me.
b) If there is a way to make the user follow me on Twitter.
Thanks in advance!
-(IBAction)twitter:(id)sender {
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:
#"About my app"];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Error"
message:#"No Internet Connection"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}}
a, send a reply:
[tweetSheet setInitialText:
#"#pantelisproios About my app"];
b, follow by sending a tweet:
[tweetSheet setInitialText:
#"follow pantelisproios"];
You can also use TWRequest if you want to use the twitter API directly.

iPhone to retrieve gmail account details in app from setting

I am making an application where I want to send an email using smtp server.
It's working fine but if user does not provide the correct gmail account details such as (email id and password) email is not send.
What I want to do is I want to access user gmail account details from setting tab of the iPhone into my app?
Is it possible to do retrieve the gmail account detail into the app?
Please help me out with this.
Following is my code:
-(IBAction)sendemail
{
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
//testMsg.fromEmail = #"Lexi mobile";//nimit51parekh#gmail.com
testMsg.fromEmail = soundOn;
NSLog(#"str_Uname=%#",testMsg.fromEmail);
//str_info = [str_info stringByReplacingOccurrencesOfString:#"," withString:#""];
testMsg.toEmail = [string_emailinfo objectAtIndex:0];
NSLog(#"autoemail=%#",testMsg.toEmail);
testMsg.relayHost = #"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = soundOn;
NSLog(#"autoelogin=%#",testMsg.login);
testMsg.pass = vibrateOn;
NSLog(#"autopass=%#",testMsg.pass);
testMsg.subject = #"Photo Sharing";
testMsg.wantsSecure = YES;
NSURL *url = [[NSURL alloc]initWithString:#"http://itunes.apple.com/us/app/umix-radio/id467041430?mt=8"];
NSString *msg2 = [NSString stringWithFormat:#"<html><b>DOWNLOAD NOW</b>&nbsp&nbsp</html>",url];
NSString *sendmsg=[[NSString alloc]initWithFormat:#"%#",msg2];
NSLog(#"automsg=%#",sendmsg);
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,
sendmsg,kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
// [self DeleteRowAfterSending];
//[self performSelector:#selector(DeleteRowAfterSending) withObject:nil afterDelay:5.0];
}
-(void)messageSent:(SKPSMTPMessage *)message
{
[message release];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Success" message:#"Your email is sent successfully" delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(#"delegate - message sent");
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
[message release];
// open an alert with just an OK button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Fail" message:#"Message sending failure" delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(#"delegate - error(%d): %#", [error code], [error localizedDescription]);
}
What i want to do is i want to access user gamil account details from
setting tab of the iPhone into my app? is it possible to do retrive
the gamil account detail into the app?
No, and with good reason: that functionality would allow any developer access to anyone's e-mail account.
That would be a massive security hole.
Much like it is with Location Services, you're just going to have to ask the user to enter their e-mail address and password. And hope they want to trust your app with that kind of personal information. (Assuming Apple approves your app at all.)
Let the user give your app authorization from Google. check the oauth autorization with google api at their developers site?
https://developers.google.com/accounts/docs/OAuth2
As usual the user signs in with his account through google api and returns back to you an access_token to get information back from his account including his email which you need.

UIAlertView from Tab Button - No Internet Connection

Looking for some help again...
I've currently got 2 sections of my app that need internet connection, 1 is a photo gallery through Flickr and the other a Twitter Feed, I was wondering if this is the correct code for the UIAlertView... I can get it working from a button but thats all!
{
-(void)didTap_roundedRectButton1:(id)sender forEvent:(UIEvent *)event {
UIAlertView *alertView = [[UIAlertView alloc] init];
alertView.title = #"You are not connected to the Internet!";
alertView.message = #"Please check your connection and try again...";
[alertView addButtonWithTitle:#"Ok"];
[alertView show];
[alertView release];
}
i think you need to use this example as i have used it to check is there any network is available and device is connected to any one of the network it is alos available on the apple's developer example site
example link is this
You should try this:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"You are not connected to the Internet!"
message:#"Please check your connection and try again..."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alertView show];
[alertView release];
and can you post the code how do you create the UIButton?

Add Pop-up for database update

I'm a new iphone developer and getting ready to launch my first app. I have an reference utility app that I developed with help from an experienced developer to provide a process to upload database update to SQLite from access. When the updates occur, I have a popup window appearing which prompts the user to accept the data update or not. However, if they accept the update I want a popup to display during the update process. What do I need to do to ad this to this code?
if( [elementName isEqualToString:#"is_update_availableResult"] )
{
if([soapResults isEqualToString:#"yes"])
{
soapResults = [[NSMutableString alloc] init];
NSString *strMessage=#"An update is available. Select OK to update or cancel to load later. Please wait while system loads data before using app. ";
altView=[[UIAlertView alloc] init];
altView.title=#"MY APP";
altView.delegate=self;
[altView addButtonWithTitle:#"OK"];
[altView addButtonWithTitle:#"Cancel"];
[altView setCancelButtonIndex:0];
altView.message=strMessage;
[altView show];
}
Use the below code to implement the progress indication for your data base operation.
Declare UIAlertView* myAlert in your class header file.
myAlert = [[UIAlertView alloc] initWithTitle:#"Updating database…" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[myAlert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(myAlert.bounds.size.width / 2, myAlert.bounds.size.height - 50);
[indicator startAnimating];
[myAlert addSubview:indicator];
[indicator release];
Once your database operation is completed dismiss the UIAlertView
-(void) OperationCompleted
{
[myAlert dismissWithClickedButtonIndex:0 animated:YES];
}