4

My application have iOS OpenVPN Connect app dependency.

So I have to check if the app is already installed or not

if so I will just Open the app using OpenURL scheme else I will open its appstore link so that user will install it.

So my problem here is I couldn't find any open url associated with this app.

Any help is appreciated !

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
karthik
  • 1,271
  • 1
  • 14
  • 27

6 Answers6

2

it exports a doctype. so you could use a UIDocumentInteractionController to check if the filetype can be opened and thus the app is installed.

uti is net.openvpn.formats.ovpn

copy a file of that type (you can make such a file on OSX) to the bundle and attempt to present an interaction controller for it using presentOpenInMenuFromRect

set yourself as delegate and if it fires willShowMenu, then you no the app is there - and you dismiss the menu.

so to get you started something like this:

NSString *file = ... //path to file with UTI in question 
UIDocumentInteractionController *c = ... //init with file
c.delegate = self;
_hasAppInstalledForUTI = NO;
[c present...];

if(!_hasAppInstalledForUTI) {
    //act
}

...

- willPresentOpenInMenu {
    [c dismissAnimated:NO];
    _hasAppInstalledForUTI = YES;
}

BTW: I checked the app -- there is no url scheme.

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • The solution above will check whether file can be opened or not.I want to check whether openvpn is installed.As I need to open my file only using openvpn app. – karthik Sep 01 '13 at 17:50
  • that uti is only used by that app AFAIK ... openvpn config files. as there is no urrl scheme and wont be there without an updated app, this is the closest you'll get – Daij-Djan Sep 01 '13 at 20:48
  • The willPresentOpenInMenu will be called if the OpenVPN is not installed, it will open the menu with Mail and message options, please see this image http://monosnap.com/image/ja8NsXVGwhxc3QpvNQx5jBGvMgP61m – Thamilan S Jan 17 '15 at 16:24
1

Whilst it might sound cheeky, I think one way would be to email the developers and ask them if they have a URL scheme, or if they would create support for one. Its a win-win because their software is more likely to be installed if it can be leveraged in new ways, and you'd get the functionality you need.

Faisal Memon
  • 2,711
  • 16
  • 30
0

To check if the user has the app at all, you would do the following:

NSURL *url = "appScheme://"
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}
else {
    // can't open url
}

But not all apps have url schemes. I know mine don't.

If you are not able to find any online, then chances are there isn't one. Try to contact the developers to find out if there even is one to begin with, otherwise try finding another app that has one, and use that one instead.

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
CaptJak
  • 3,592
  • 1
  • 29
  • 50
  • 1
    thanks for your response, I have the above code ,I am searching for url scheme for open vpn app – karthik Aug 28 '13 at 15:34
  • Well, as I said, they might not have one. Try sending an email to the developers of the open vpn app and ask them. – CaptJak Aug 28 '13 at 15:59
  • @Daij-Djan you're not an answer. This is precisely the answer. Use `openvpn://` and read FAQ https://docs.openvpn.net/docs/openvpn-connect/openvpn-connect-ios-faq.html – pronebird Dec 19 '16 at 20:05
  • Don't insult me. All ok with you? And this was still no answer in 2013. Now i don't know – Daij-Djan Dec 19 '16 at 20:19
0

You try to open an .ovpn file.

Here's an old question from myself to get you started on how to do that.

Source.

Though this is not specifically check that particular app, but it should do the job.

Community
  • 1
  • 1
marko
  • 1,721
  • 15
  • 25
  • 100% what I wrote above just as a link ;) – Daij-Djan Sep 01 '13 at 14:51
  • I dont want to show open-in using UIDocumentInteractionController, I need to check whether openvpn is installed or not.I need custom url scheme , as I know the implementation – karthik Sep 01 '13 at 17:40
0

I think you want to open "openvpn ios" application from your application. Please check the below link for same :

http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-working-with-url-schemes/

Follow the steps as it said and check whether application is opened or not.

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • Napster,I want to check "openvpn ios" is installed or not.I know to check it using url scheme, I want to know the url scheme or any alternate way to achieve the same. – karthik Sep 06 '13 at 18:55
  • 1
    Karthik: You can check whether application is installed or not with below code : NSString *ourPath = [@"appURLSheme://" stringByAppendingString:URLEncodedText]; NSURL *ourURL = [NSURL URLWithString:ourPath]; if ([ourApplication canOpenURL:ourURL]) [ourApplication openURL:ourURL]; else NSLog(@"There is no application installed."); – Nirmalsinh Rathod Sep 07 '13 at 04:34
  • Napster,I know to check using urlscheme, I am searching for openvpn url scheme,or alternate way to achieve the same. – karthik Sep 07 '13 at 05:17
  • you can open with above code. Need to check about alternate if possible. Will update you if I got any solution for you. – Nirmalsinh Rathod Sep 07 '13 at 05:19
0

Support for openvpn:// URL scheme was introduced in OpenVPN Connect 1.0.6, according to OpenVPN Connect FAQ you can use this code:

BOOL installed = [application canOpenURL:[NSURL URLWithString:@"openvpn://"]];

Following code opens iTunes to install OpenVPN Connect if it is not installed yet:

UIApplication * app = [UIApplication sharedApplication];
BOOL installed = [app canOpenURL:[NSURL URLWithString:@"openvpn://"]];
if (installed) {
    [app openURL: [NSURL URLWithString:@"openvpn://"]];
} else {
    [app openURL: [NSURL URLWithString: @"https://itunes.apple.com/app/id590379981?mt=8"]];
}

EDITED: actually this approach DOES NOT work, I have just tested myself - the matter is that published version of OpenVPN Connect in AppStore is 1.0.5, so this feature is not available in it ((

Mixaz
  • 4,068
  • 1
  • 29
  • 55