Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
fix attribution links and add canopen cordova plugin to detect if goo…
Browse files Browse the repository at this point in the history
…gle maps app is installed before launching directions
  • Loading branch information
Ethan Sutin authored and Ethan Sutin committed Oct 27, 2014
1 parent 2e58b02 commit cd3fb58
Show file tree
Hide file tree
Showing 62 changed files with 9,213 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/com.philmerrell.cordova.canopen/.fetch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"source":{"type":"git","url":"https://github.com/philbot5000/CanOpen.git","subdir":"."}}
81 changes: 81 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
CanOpen
======
This plugin is useful for checking if native apps are installed on a user's iOS or Android device. By passing an app scheme (e.g., 'fb://', 'gplus://', 'instagram://', etc...), CanOpen returns true if it detects the user has the corresponding native app installed. By returning false, CanOpen allows the developer the ability to implement a fallback URL–for instance, the app's location in the App Store, or a mobile web version of the corresponding app. A blog post for this plugin can be found at <a href="http://philmerrell.com/canopen-a-phonegap-plugin-to-check-if-native-apps-are-installed-on-a-users-ios-device/" target="_BLANK">http://philmerrell.com/canopen-a-phonegap-plugin-to-check-if-native-apps-are-installed-on-a-users-ios-device/</a>

## Manual Installation for iOS

Copy the following files to your project's Plugins folder:

**CanOpen.h**<br />
**CanOpen.m**


Add a reference for this plugin to **config.xml** in your iOS phonegap project:

```
<feature name="CanOpen">
<param name="ios-package" value="CanOpen" />
</feature>
```

Add the **canOpen.js** script to your www folder and reference it in your main index.html file.

<script type="text/javascript" charset="utf-8" src="canOpen.js"></script>

## Automatic Installation

Working on registering CanOpen with plugman. Coming soon.

Usage:
-------

**Alert a user that app is not installed.**

```javascript
CanOpen('fb://', function(isInstalled) {

if(isInstalled) {

document.location = 'fb://';

} else {

alert('Facebook is not installed');

}
});
```

**Or fallback to mobile web.**

```javascript
CanOpen('fb://', function(isInstalled) {

if(isInstalled) {

document.location = 'fb://';

} else {

document.location = 'http://m.facebook.com';

}
});
```

**Or fallback to app in the App Store.**

```javascript
CanOpen('fb://', function(isInstalled) {

if(isInstalled) {

document.location = 'fb://';

} else {

document.location = 'https://itunes.apple.com/us/app/facebook/id284882215';

}
});
```
34 changes: 34 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.philmerrell.cordova.canopen" version="0.1">
<name>CanOpen</name>
<author>Phil Merrell, Bryan Wokich</author>
<description>CanOpen is useful for checking if native apps are installed on a user's device in iOS or Android.
</description>
<license>Apache 2.0</license>
<keywords>cordova, phonegap, canopen, canopenurl, url, scheme</keywords>
<engines>
<engine name="cordova" version=">=3.0.0"/>
</engines>
<js-module src="www/canOpen.js" name="canopen">
<clobbers target="window.CanOpen"/>
</js-module>
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="CanOpen">
<param name="ios-package" value="CanOpen"/>
</feature>
</config-file>
<header-file src="src/ios/CanOpen.h"/>
<source-file src="src/ios/CanOpen.m"/>
</platform>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="CanOpen">
<param name="android-package" value="com.soundsoftware.canopen.CanOpen"/>
</feature>
</config-file>

<source-file src="src/android/CanOpen.java" target-dir="src/com/soundsoftware/canopen"/>
</platform>
</plugin>
33 changes: 33 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/src/android/CanOpen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.soundsoftware.canopen;

import java.util.List;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
import org.apache.cordova.PluginResult.Status;
import org.json.JSONArray;
import org.json.JSONException;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;

public class CanOpen extends CordovaPlugin {

@Override
public boolean execute(String action, JSONArray args,
final CallbackContext callbackContext) throws JSONException {

PluginResult pr;
Uri uriToTest = Uri.parse(args.getString(0) + "://");
Intent intent = new Intent(Intent.ACTION_DEFAULT, uriToTest);
PackageManager packageManager = cordova.getActivity().getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
pr = new PluginResult(Status.OK, isIntentSafe);
callbackContext.sendPluginResult(pr);
return false;
}
}
15 changes: 15 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/src/ios/CanOpen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// CanOpen.h
// CanOpen
//
// Created by Phil Merrell on 10/25/13.
//
//

#import <Cordova/CDV.h>

@interface CanOpen : CDVPlugin

- (void)appCanOpen:(CDVInvokedUrlCommand*)command;

@end
33 changes: 33 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/src/ios/CanOpen.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// CanOpen.m
// CanOpen
//
// Created by Phil Merrell on 10/25/13.
//
//

#import "CanOpen.h"
#import <Cordova/CDV.h>

@implementation CanOpen

-(void) appCanOpen:(CDVInvokedUrlCommand*)command {
CDVPluginResult* pluginResult = nil;
NSString* appUrl = [command.arguments objectAtIndex:0];

if (appUrl != nil && [appUrl length] > 0) {

NSURL *url = [NSURL URLWithString: appUrl];
BOOL result = [[UIApplication sharedApplication] canOpenURL: url];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:result];

} else {

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];

}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@end
14 changes: 14 additions & 0 deletions plugins/com.philmerrell.cordova.canopen/www/canOpen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = function CanOpen(app, callback) {
cordova.exec(
// Success callback
callback,
// Failure callback
function(err) { console.log('Missing app scheme.');},
// Native Class Name
"CanOpen",
// Name of method in native class.
"appCanOpen",
// array of args to pass to method.
[app]
);
};
1 change: 1 addition & 0 deletions plugins/org.apache.cordova.inappbrowser/.fetch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"source":{"type":"registry","id":"org.apache.cordova.inappbrowser"}}
37 changes: 37 additions & 0 deletions plugins/org.apache.cordova.inappbrowser/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->

# Contributing to Apache Cordova

Anyone can contribute to Cordova. And we need your contributions.

There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.

For instructions on this, start with the
[contribution overview](http://cordova.apache.org/#contribute).

The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
- Have a Jira issue open that corresponds to your contribution.
- Run the tests so your patch doesn't break existing functionality.

We look forward to your contributions!
Loading

0 comments on commit cd3fb58

Please sign in to comment.