Naren
Naren

Reputation: 23

How to avoid default alert when using OpenUrl with tel://2373829239

How do you avoid the default iOS alert when using OpenUrl with tel://2373829239?

I am getting a push notification with a number and options such as 'Call' and 'Cancel'. When the user presses 'Call' again a default iOS alert appears which means the user has to press the 'Call' button twice to make a call. This is undesired so I was wondering how can I avoid this situation.

Upvotes: 1

Views: 807

Answers (2)

P.J
P.J

Reputation: 6587

Try this :-

NSString *callString;
callString = @"12345";
        NSString *URLString = [@"tel://" stringByAppendingString:callString];
        NSURL *URL = [NSURL URLWithString:URLString];
        [[UIApplication sharedApplication] openURL:URL];

OR

NSString *urlString = [NSString stringWithFormat:@"tel:123"];
            NSString *escaped = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];

Hope it helps you..

Upvotes: 0

occulus
occulus

Reputation: 17012

You can't avoid this situation. Apple want their iOS to help you avoid making a phone call by accident, which sounds sensible to me.

Upvotes: 2

Related Questions