Created
March 21, 2014 06:34
-
-
Save hebertialmeida/9680780 to your computer and use it in GitHub Desktop.
Open native Apps or open on Safari if don't have the App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)openThisURL:(NSString *)launchUrl withFallback:(NSString *)fallback | |
{ | |
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:launchUrl]]) { | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:launchUrl]]; | |
} else { | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fallback]]; | |
} | |
} | |
// Usage | |
- (IBAction)didTouchOnButton:(UIButton *)sender | |
{ | |
[self openThisURL:@"twitter://user?screen_name=hebertialmeida" withFallback:@"https://twitter.com/hebertialmeida"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment