Skip to content

Instantly share code, notes, and snippets.

@rahulinaction
Last active August 29, 2015 14:05
Show Gist options
  • Save rahulinaction/9337f8dd5618955d4762 to your computer and use it in GitHub Desktop.
Save rahulinaction/9337f8dd5618955d4762 to your computer and use it in GitHub Desktop.
PhoneDialer header file
#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
@interface PhoneDialer : CDVPlugin
- (void) dialPhone:(NSMutableArray *)arguments withDict:(NSMutableDictionary *) options;
@end
#import "PhoneDialer.h"
@implementation PhoneDialer
- (void) dialPhone:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options {
NSString* ph = [options valueForKey:@"number"];
UIDevice *device = [UIDevice currentDevice];
if ([[device model] isEqualToString:@"iPhone"] ) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", ph]]];
} else {
UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[Notpermitted show];
[Notpermitted release]; /*Remove this if it is a ARC Project*/
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment