Friday, 4 April 2014

Open other apps from iOS app using URL scheme. Open google maps, mail from the app, call a number, send sms using Xcode.

Use openURL: function of UIApplication.


[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];


Call a number:

-(void)makeCall
{
    UIDevice *device = [UIDevice currentDevice];
    
    if ([[device model] isEqualToString:@"iPhone"] )
    {
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",@"phone number"]];
        [[UIApplication sharedApplication] openURL:url];
    }
    else
    {
        NSString *stringNotSupportFeature = [NSString stringWithFormat:@"Your device doesn't support calling feature. You can call on:\n%@",@"phone number"];
        
        NSString *stringNotSupportFeature1 = NSLocalizedString(stringNotSupportFeature, NULL);
        
        //Alert show
        
    }
    
}


Open The Google Maps:

// Create string for the place ...
NSString* placeStr = @"1 Infinite Loop, Cupertino, CA 95014";
// Encode URL encode
placeStr =  [addressText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// Now create the URL string ...
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", placeStr];
// use openURL to launch the app ...
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];





Mail from the app:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://info@example.com"]];



Send SMS:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:55555"]];




Open App Store:

[[UIApplication sharedApplication]  openURL:[NSURL URLWithString:@"app url"]];








1 comment:

  1. Excellent…Amazing…. I’m satisfied to find so many helpful information here within the put up,for latest php jobs in near me. we want work out extra strategies in this regard, thanks for sharing.

    ReplyDelete