This is most likely a very obvious answer, but I am just not seeing it. I want to open the phone application when I click a button.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://???????"]];
That line of code should do it. The problem is, depending on what happens in the app, I want it to dial a different number. I made a string variable, and I want to put it into the space with the ???
Something like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://(myPhoneNumberString)"]];
Any ideas?
Thanks
Take a look at the NSString documentation.
Something like that will work:
[ NSURL URLWithString: [ NSString stringWithFormat: #"tel://%#", myPhoneNumberStringVar ]
String format is basically the same as in the printf C function, with the additional %# format, used to print object representations.
Related
I can't share Burmese, but I can share English
NSString * const viberScheme = #"viber://forward?text=မဂ်လာပါဂိမ်းကစားကြမယ်";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:viberScheme]];
Actually, it works fine. Maybe check the quotation marks in the url-schema you used?
You can encode the text and it will work also.
Like
viber://forward?text="%E1%80%99%E1%80%82%E1%80%BA%E1%80%9C%E1%80%AC%E1%80%95%E1%80%AB%E1%80%82%E1%80%AD%E1%80%99%E1%80%BA%E1%80%B8%E1%80%80%E1%80%85%E1%80%AC%E1%80%B8%E1%80%80%E1%80%BC%E1%80%99%E1%80%9A%E1%80%BA"
I am facing an issue while dialing a call as it is automatically assigning international or local prefixes when making calls for toll free local numbers Which starts with one to ISD
NSString *phNo = #"18605003000";
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",phNo]];
NSLog(#"in call");
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
[[UIApplication sharedApplication] openURL:phoneUrl];
}
For above code, when Dail assist is ON, it is prefixing number and converting with +1 (860) 500-3000 which is actually a Indian toll free redirecting to ISD to call ..To avoid this I want to check whether Dail assist is ON or way to disable this programatically.
I have even referred this iOS dial assist auto formats local number to USA number but this way it is Dailing to wrong number
So can any please suggest me for possible way?
I tried the code, and had the dial assist on, but it dialed "18005003000" and did not converted to +1 (800) 500-3000
NSURL *url = [NSURL URLWithString:#"tel://18005003000"];
[[UIApplication sharedApplication] openURL:url];
I am trying to find direction between two location using iOS framework but I am not able to find proper solution .
You can use different methods for finding the direction between two location.
(1) Using Google Maps
NSString *urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
(2) Using Apple Maps:
NSString *urlString = [NSString stringWithFormat:#"http://maps.apple.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Please let me know if you need any help.
your question is not very clear, but i think you mean the bearing between two locations.
see this question:
Calculating bearing between two CLLocationCoordinate2Ds
If your points are close together just use trigonometry. That will be close enough. If they are farther away then you want a great circle course, use the Haversine formula.
In my app I have a UITableView displaying tweets from a downloaded json file. Many of the tweets contain a link (to Instagram for example). How would I go about making these links open in Safari? What code would I need?
[[UIApplication sharedApplication] openURL:myurl];
Or is your problem elsewhere?
If that doesn't solve the problem, some code would be helpful to show what your table view cells look like.
First of all you will need to detect your links. Is the link part of the tweet string or is it a separate object in an array?
NSString *yourLink = #""; //we will need more detail in your question for this.
Once you have your link you need to store it as an NSURL like so:
NSURL *url = [[NSURL alloc] initWithString:yourLink];
And then you can open this in a browser using:
[[UIApplication sharedApplication] openURL:url];
It would be useful to see what you are displaying in your table. Is it an NSArray from your JSON, or an NSDictionary?
I want to generate some program output and display it in Safari.
Alternatively I could display it in a UIWebView if there were a simple method for providing a Print button and then have printing occur.
Currently my approach is to save my HTML to a file, generate a full path, and then try to invoke Safari like so:
NSString *str = [[NSString alloc] initWithUTF8String: htmlpath];
NSURL *url = [NSURL URLWithString: str];
[[UIApplication sharedApplication] openURL:url];
But this is not working. Can somebody tell me what I'm doing wrongly? Thanks.
Apps in iOS are sandboxed, so Safari cannot access the contents of your app.
If you simply want to print it, I suggest you use a UIWebView.