Created
November 10, 2016 16:35
-
-
Save drewlarsen/2fbf0c93e990dbe8848e028b861fac2d to your computer and use it in GitHub Desktop.
Sample code to open the SugarWOD iOS app with the URL Link Scheme
This file contains 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
#pragma mark URL SCHEME TESTING | |
- (IBAction)launchButtonTouchUpInside:(UIButton *)sender { | |
// Sample code to open the SugarWOD iOS app from another app | |
// will attempt to open the app, | |
// if app is not installed, | |
// will re-direct to the SugarWOD page in the app store or in Safari | |
// SugarWOD URL Scheme | |
NSURL *url = [NSURL URLWithString:@"sugarwod://"]; | |
if ([[UIApplication sharedApplication] canOpenURL:url]) { | |
// open sugarwod app | |
[[UIApplication sharedApplication] openURL:url]; | |
} else { | |
// open in app store | |
NSURL *url = [NSURL URLWithString:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=665516348"]; | |
if ([[UIApplication sharedApplication] canOpenURL:url]) { | |
// open in iTunes app | |
[[UIApplication sharedApplication] openURL:url]; | |
} else { | |
// open in Safari | |
url = [NSURL URLWithString:@"http://itunes.com/app/sugarwod"]; | |
[[UIApplication sharedApplication] openURL:url]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment