here I add some sample for Uber
customize your self , the reason we don't know what your urlScheme
contains
for example
Swift
func share(urlScheme: String)
{
if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"uber://")!))
{
// if your app is available it open the app
UIApplication.sharedApplication().openURL(NSURL(string: string:"uber://?openapp")!)
}
else
{
open web version somehow
// it redirect to safari, safari directly open the web page on uber application, it does not redirect to app store
UIApplication.sharedApplication().openURL(NSURL(string: string:"http://m.uber.com/?opneapp")!)
}
}
Objective-C
NSString *getUberDetails=[NSString stringWithFormat:@"client_id=vbtCwkGyqvDupQhpCcgCMo4VE-gIRw42&action=setPickup&pickup[latitude]=%f&pickup[longitude]=%f&pickup[nickname]=OuttAPP&dropoff[latitude]=%f&dropoff[longitude]=%f&dropoff[nickname]=%@&product_id=%@",[latitude floatValue],[longitude floatValue],[droplatitude floatValue],[dropLongtitude floatValue],[dropAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[[huberTableArr objectAtIndex:indexPath.row]objectForKey:@"productID"]];
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"uber://"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"uber://?%@",getUberDetails]]];
}
else
{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:[NSString stringWithFormat:@"http://m.uber.com/?%@",getUberDetails]]];
}
}