I have a button when user click it and it launch the map app to show the direction to the destination.
NSURL *mapURL = [NSURL URLWithString:#"http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino"];
[[UIApplication sharedApplication] openURL:mapURL];
and I found on iOS 8.1 it only opens once and it won't work the second time or third time.
I had to uninstall the app and re-install it again to make it work.
And the view was nested in a navigation hierarchy.
any ideas?
Related
I have simple code
NSURL *url = [NSURL URLWithString:#"https://en.wikipedia.org/wiki/Cat"];
if ([SFSafariViewController class] != nil) {
SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:url];
[self presentViewController:sfvc animated:YES completion:nil];
} else {
[[UIApplication sharedApplication] openURL:url];
}
I've tested on iOS 9.3. When I first open url I can see the page in mobile mode.
(Picture 1)
Next I click Desktop. And I can see this page (Picture 2)
(Picture 2)
I restarted application and SFSafariViewController still opens page in Desktop mode (Picture 2).
Can I force open the url in the mobile mode using SFSafariViewController and How Can I do this?
The "Desktop" link in this context means the user will see what s/he would normally see when clicking on their Macintosh or PC. This is expected behavior.
If you suspend and then resume the application, especially when SFSafariViewController is visible to the user, the app will resume on the same page where it was left off, unless you tell it to re-open the original URL (which you can do by having your application delegate watch for applicationWillEnterForeground: and then force reload the view controller).
if it were working fine, then all you need to do is to click mobile view in wikipedia footer, otherwise rebuild your app and clean it, it will restore the default behavior
The final solution that I found, It's using specific links with a prefix (m.) that the server supports, It will force open the urls with the mobile mode:
NSURL *url = [NSURL URLWithString:#"https://en.m.wikipedia.org/wiki/Cat"];
I have this code snippet that will open my app specific settings screen.
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
But I want the user to be taken to the main iPhone Settings screen instead of app specific screen. I have been searching for this over the last few days and not able to find a way. Is it possible to do this navigation?
I tried this in Swift and It took me to main settings screen.
UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!)
I have call button in my view controller in my application. when i will click on call button, it will show my iPhone call keypad with some number.
I am not getting any solution for this. Please help me.
Thank-you
Before you think I am, I am not the Popeye that has supplied the other answer.
Right down to my answer. There are a couple of ways you can do this
// Pick one of the two ways from below, one will return you to the app afterwards the other will not.
// This version of of creating the number will open the dialer but will not return you to the app afterwards.
NSURL *phoneNumber = [NSURL urlWithString:[NSString stringWithFormat:#"tel://%#", yourNumberString]];
// Whilst this version will return you to your app once the phone call is over.
NSURL *phoneNumber = [NSURL urlWithString:[NSString stringWithFormat:#"telprompt://%#", yourNumberString]];
// Now that we have our `phoneNumber` as a URL. We need to check that the device we are using can open the URL.
// Whilst iPads, iPhone, iPod touchs can all open URLs in safari mobile they can't all
// open URLs that are numbers this is why we have `tel://` or `telprompt://`
if([[UIApplication sharedApplication] canOpenURL:phoneNumber]) {
// So if we can open it we can now actually open it with
[[UIApplication sharedApplication] openURL:phoneNumber];
}
Hope this helps if you have any questions please just ask.
iPhone SDK doesn't gives you direct access to dial numbers from the app.So,you can't do this,but there is a way to achieve this.
-> Have a TextField(yourPhoneNumber) with keyBoardType UIKeyboardTypePhonePad.
-> [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#",yourPhoneNumber.text]]];
Hope this will help you out.
I need to make a call from my iOS app, and after the user is done calling, i need him to come back on the same app screen from where he made the call. if i use the following code
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i achieve what i want, but get an unwanted alert confirming if the user wants to make a call or not. I don't want this.
If i use the code
NSString *phoneNumber = [#"tel://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i do not get the alert, but i do not get back to my app screen too..!!
Is there a way where i do not get the alert while making the call and get back to the app screen after making the call?? please help..
You cannot do otherwise, those are the two possibilities. telprompt with alert and callback or tel with not coming back and no alert.
If the users leaves the app to make a phone call, there's no way you can return to your app after it. Your app is backgrounded, and the phone app is foregrounded.
i'm working on a jailbroken iphone with iOS 5.0.1, just want to access status bar image,
and my code is as follows:
-(void)addStatusBarImage
{
NSLog(#"addStatusBarImage");
[[UIApplication sharedApplication] addStatusBarImageNamed:#"sgtest" removeOnExit: YES];
}
-(void)removeStatusBarImage
{
NSLog(#"removeStatusBarImage");
[[UIApplication sharedApplication] removeStatusBarImageNamed:#"sgtest"];
}
my problem is, the add function works fine, but removeStatusBarImageNamed seems useless as the "sgtest" image still exists in the status bar unless my app is terminated.
status bar icon manager fix what thread have had set icon image. if another thread try to remove that icon, it fails. You need to do it in one thread.
Check out SpringBoardAccess project at github. You can use it as is or implement like.