Open Twitter app in html - iphone

Is there anyway to open the twitter app from an html link on an iPhone? Kind of how when you click a youtube link it goes to the youtube app.
thanks

You'd use twitter:// as the URL and put it in an action for a button or something like so:
-(IBAction)openTwitter{
NSURL* url = [NSURL URLWithString:#"twitter://"];
[[UIApplication sharedApplication] openURL:url];
}
If you meant html on a website you'd use tap me to go to twitter for the link.
URL Schemes are shown here and you can grab some more handy information about them too.
I'd probably recommend #Arab_Geek's solution though as it isn't that much of a trouble and it's giving back control to the user.

Why don't you use Twitter integratation for iOS 5 (TWTweetComposeViewController) ?

NSURL * twitterURL = [NSURL URLWithString:#"twitter://"];
if([[UIApplication sharedApplication] canOpenURL:twitterURL])
[[UIApplication sharedApplication] openURL:twitterURL];

Related

Open Setting App from my applicaiton in iPhone iOS 7

I want to open iphone default setting application form my application, Please any one tell me what I have to do. OR is there any code to open it.
I try following code but it dont works.in iOS 7.1.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES_Systemservices"]];
Thanks in Advance.
For iOS8 and later use :
// Send the user to the Settings for this app
//iOS 8 only
NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:settingsURL];
Since iOS 5.1, there is no official way to open Settings via App.
Here to Go.
You can use private API to open Settings App from your application. But i'm not sure if it will get accepted from apple.
void (*openApp)(CFStringRef, Boolean);
void *hndl = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", 0);
openApp = dlsym(hndl, "SBSLaunchApplicationWithIdentifier");
openApp(CFSTR("com.apple.Preferences"), FALSE);
Swift 4
let url = URL(string: UIApplicationOpenSettingsURLString)
if UIApplication.shared.canOpenURL(url!) {
UIApplication.shared.openURL(url!)
}

Open Google Maps App in iOS 6

I would like to open Google Map App in iOS 6 programmatically.
I tried to open the maps in by passing url - maps.....
but it is still opening in the Safari
[[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:#"comgooglemaps://"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
#"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
reference: https://developers.google.com/maps/documentation/ios/urlscheme
try this
The domain must be maps.apple.com.
A parameter cannot be q=* if the value is a URL (so KML is not picked up).
The parameters cannot include view=text or dirflg=r.
https://developer.apple.com/library/safari/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html#//apple_ref/doc/uid/TP40007894-SW1

How to make link open "Maps" window when clicked

I would like to have a link in a web page in such a way that when the link is clicked it opens the standard "Maps" view in iPhone.
If such a thing is possible, what tag format do I need to use with the link?
It's pretty simple; you don't even need to use a specific scheme identifier. Any Google Maps URL will be opened with the Maps app automatically, as long as all the parameters are supported.
So links like these:
http://maps.google.com/maps?q=cupertino
http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino
Would automatically be opened in Maps. To find out more about what works and what doesn't see the Map Links page from the Apple URL Scheme Reference.
I used this code which works passing longitude lattitude:
NSString *url = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=%f,%f&daddr=%#",cur_lat, cur_lon,[loc stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(#"current %f %f",cur_lat,cur_lon);
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];

Is there a way for an iPhone app to open safari up at the existing page (not a new window or new url)

I have an iPhone app and I need it to open up Safari in the same manner as when you tap on it (just opens the window you were last browsing at). I don't want to open a new window or call a new url.
Is this possible?
Thanks
I think its not possible as you have to pass an URL with :
[[UIApplication sharedApplication] openURL:url];

How can I make iPhone hotspot login UIWebView open a link in Safari?

We have a wifi hotspot that displays a terms of service page before people are allowed to start using it.
After acceptance, a new page with a few links is displayed. I'd like to have those links open in Safari instead of in UIWebView.
I know there's a way to program UIWebView to open links in Safari, but that's not an option as this is the default UIWebView for logging into wifi hotspots and not a custom app.
Is there another way to have the links open in Safari and not in UIWebView? I've tried javascript and I've tried setting the target to _blank.
EDIT: After reading some responses, it seems like the only way to do this is to set the UIWebView delegate. I don't think this is an option because I'm not the one launching the UIWebView.
When the iPhone connects to the network (at least with version 3.0), it checks to see if it's being redirected to a login page. If it is, it does what you're saying with authentication and such inside of a UIWebView. Have you checked to see what it's reporting as the browser in use? If it isn't Mobile Safari, then you could do something server-side the first time someone connects using Mobile Safari.
If it does report as Mobile Safari when it's checking redirection, then another alternative is to figure out what site it tries to go to - maybe apple.com? Then, on the server side, the first time a different URL is loaded, redirect to your links. This will only work when the user opens Mobile Safari, however.
Other than that, I think what you're asking to do is outside of the scope of the current iPhone OS. I'd recommend filing a ‘feature request’ with Apple at bugreport.apple.com.
The only way I know how to do this is to set up a UIWebView delegate and supply something like the following:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
if (navigationType == UIWebViewNavigationTypeLinkClicked &&
[request.URL isFileURL] == false)
{
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
return YES;
}
The code above will cause Safari to open a link clicked on by the user. I know you said you had little control over this UIWebView -- perhaps you have more than you think by setting the delegate?
Use the openURL method of UIApplication:
NSURL *url = [[NSURL alloc] initWithString:#"http://example.com"];
[[UIApplication sharedApplication] openURL:url];
[url release];
An Apple example of this is available as part of the LaunchMe sample.