openurl

UIApplication.sharedApplication() is unavailable

谁说我不能喝 提交于 2019-11-28 13:20:50
I just upgraded from XCode 6.4 to Xcode 7 GM and get started to change the code to be compliant with Swift 2. I could not come over the following errors. The project is a keyboard extension and the snippet is from the containing app. let s = "https://itunes.apple.com/" UIApplication.sharedApplication().openURL(NSURL(string : s)!) Error 1: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead. Error 2: 'openURL' is unavailable. This might be something to do with Xcode and AppDelegate, I might have screwed up my project. You can't access every API

UIApplication openURL background

烂漫一生 提交于 2019-11-27 23:12:29
In my iOS 4 application, I need to open a URL from the background, at a time specified from the user. However, for some reason, I cannot launch a URL from the background for some reason. Here is my code for opening a URL: if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.stackoverflow.com"]]) { // the URL wasn't opened. we will ignore this for now. } That code is all being launched from a daemon thread created earlier. I have tested this code on the simulator, and the URL is not opened, and the method returns YES for some reason, but when I open my application

openURL from App Extension

独自空忆成欢 提交于 2019-11-27 22:11:35
On iOS 8 beta 2 it should be possible to use openUrl from app extension as written into the release notes: however when I try to use this API (on Xcode 6 beta 2) I get the following error: Beta 2 really fixed this issue or not? Laurence Fan you may use this code: [self.extensionContext openURL:url completionHandler:^(BOOL success) { NSLog(@"fun=%s after completion. success=%d", __func__, success); }]; the API document: openURL:completionHandler: you could also refer to this question: openURL not work in Action Extension Accepted solution only works in Today extensions , a working solution in

Can an iOS App Switch to Safari Without Opening a Page?

我的梦境 提交于 2019-11-27 19:33:49
I know that my app can open a particular URL in Safari by doing something like this: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.example.com/"]]; but, is there any way to have my app switch over to Safari without opening a URL? I'd like to switch to Safari, but let it keep showing whatever page it had open the last time the user looked at it. Unfortunately no, unless you can figure out how to launch an app by bundle id in a non-jailbroken environment. Otherwise, if you are in a jailbroken environment, you can use the following to launch an app by its bundle id:

ios 8 openUrl itms-services does not exit current app

天涯浪子 提交于 2019-11-27 13:43:17
问题 In iOS 6 or 7, the app exit to the home screen when I call UIApplication openUrl with a url of itms-services://XXXX to install a new version of my app (using enterprise deployment with ipa files). In iOS 8, this is no longer the case. Now the app continue running just as nothing has happened, but if I go the home screen, I can see my app icon grayed out, with a downloading pie chart about 66% completed and the text "Downloading..." below. If I now wait for a while (less than a minute), the

OpenUrl freezes app for over 10 seconds

假如想象 提交于 2019-11-27 10:07:55
问题 I'm currently developing an App, that needs to open a browser to display a webpage. To do that i use the [UIApplication sharedApplication] openURL method with an url. In iOS 6 this works perfectly, but in iOS 7 it freezes the app for 10+ seconds, then opens the browser and all is good. This happens using ad hoc provisioning. Someone on the internet commented that this was a known problem, however, that one comment was all i could find regarding this problem. 回答1: I noticed the same problem

How to use openURL for making a phone call in Swift?

别来无恙 提交于 2019-11-27 07:45:58
I have converted the code for making a phone call from Objective-C to Swift, but in Objective-C, we can set the type of the URL that we like to open (e.g. telephone, SMS, web) like this: @"tel:xx" @"mailto:info@example.es" @"http://stackoverflow.com" @"sms:768number" The code in Swift is: UIApplication.sharedApplication().openURL(NSURL(string : "9809088798") I read that have not released any scheme parameter for tel: , but I don't know if Swift can detect if the string is for making a phone call, sending email, or opening a website. Or may I write: (string : "tel//:9809088798") ? I am pretty

OpenURL in iOS10

微笑、不失礼 提交于 2019-11-27 07:04:06
So apparently OpenURL has been deprecated in iOS 10. Does anyone have any documentation on why or can explain what to do next? I looked on the Apple site already and found a few things pertaining to OpenURL and this is what they say to use now: UIApplication.shared().open(url: URL, options: [String: AnyObject], completionHandler: ((Bool) -> Void)?) Does anyone have any evidence that this is the new way to use OpenURL in Swift 3.0? In addition what values are to be used in the options: and completionHandler: parameters respectively? You can also use conditional check if you are updating you app

OSX Swift open URL in default browser

徘徊边缘 提交于 2019-11-27 00:09:24
问题 How to open a url in system default browser by using Swift as programming language and OSX as plattform. I found a lot with UIApplication like UIApplication.sharedApplication().openURL(NSURL(string: object.url)) but this works just on iOS and not on OSX And the Launch Services, I found has no examples for swift and there is a lot deprecated for OSX 10.10 Any help welcome - thanks. 回答1: Swift 3 or later import Cocoa let url = URL(string: "https://www.google.com")! if NSWorkspace.shared.open

Can an iOS App Switch to Safari Without Opening a Page?

半世苍凉 提交于 2019-11-26 22:49:06
问题 I know that my app can open a particular URL in Safari by doing something like this: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.example.com/"]]; but, is there any way to have my app switch over to Safari without opening a URL? I'd like to switch to Safari, but let it keep showing whatever page it had open the last time the user looked at it. 回答1: Unfortunately no, unless you can figure out how to launch an app by bundle id in a non-jailbroken environment.