Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Domingos Gomes authored and Domingos Gomes committed Jan 13, 2017
2 parents b8b5e69 + ede6812 commit ab9a294
Show file tree
Hide file tree
Showing 30 changed files with 462 additions and 183 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

.DS_Store
node_modules
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"predef": [
"document",
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode7.1
osx_image: xcode8
env:
- PATH=$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin
git:
Expand All @@ -8,9 +8,9 @@ node_js:
- "4.1"
install:
- npm install -g ios-sim
- npm install -g ios-deploy
- npm install
- npm link
before_script:
- ios-sim start --devicetypeid=iPhone-6
script:
- cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR} --verbose
- FIX_PARAMEDIC=true cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR} --verbose
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ChangeLog

## Version 0.6.0 - 15.04.2016

- Support for Android 6 new permission acquiring model
- Support for Cordova 6.0
- Fix for notification permissions on iOS 8
- Removed unnecessary WRITE_STORAGE permissions on Android
- initialize method fails when required permissions are not granted

## Version 0.5.0 - 09.11.2015

- Support for new Google API
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -199,4 +200,4 @@
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.
limitations under the License.
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

machine:
environment:
ANDROID_NDK_HOME: $ANDROID_NDK
Expand Down
331 changes: 187 additions & 144 deletions hooks/add_swift_support.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions hooks/install_prerequisites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
console.log("Running hook to install push notifications pre-requisites");

module.exports = function (context) {
var child_process = context.requireCordovaModule('child_process'),
deferral = context.requireCordovaModule('q').defer();

var output = child_process.exec('npm install', {cwd: __dirname}, function (error) {
if (error !== null) {
console.log('exec error: ' + error);
deferral.reject('npm installation failed');
}
else {
deferral.resolve();
}
});

return deferral.promise;
};
17 changes: 17 additions & 0 deletions hooks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"dependencies": {
"xcode":"^0.8.3",
"xmldom":"0.1.15",
"xmlbuilder": "2.2.1",
"util-deprecate": "1.0.0",
"stream-buffers": "~0.2.3",
"simple-plist": "0.0.4",
"plist": "1.1.0",
"pegjs": "0.6.2",
"node-uuid": "1.3.3",
"lodash-node": "~2.4.1",
"bplist-parser": "0.0.6",
"bplist-creator": "0.0.4",
"base64-js": "0.0.6"
}
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-geofence",
"version": "0.5.0",
"version": "0.6.0",
"description": "Cordova geofence plugin",
"cordova": {
"id": "cordova-plugin-geofence",
Expand All @@ -12,6 +12,9 @@
"windows"
]
},
"scripts": {
"test": "cordova-paramedic --platform android --plugin ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/cowbell/cordova-plugin-geofence.git"
Expand Down Expand Up @@ -39,8 +42,9 @@
"version": ">=5.0.0"
}
],
"typings": "./typings/cordova-plugin-geofence.d.ts",
"devDependencies": {
"cordova": "^5.0.0",
"cordova-paramedic": "^0.4.0"
"cordova": "^6.1.1",
"cordova-paramedic": "https://github.com/apache/cordova-paramedic"
}
}
24 changes: 16 additions & 8 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
<clobbers target="geofence" />
</js-module>

<dependency
id="es6-promise-plugin"
url="https://github.com/vstirbu/PromisesPlugin.git">
</dependency>
<!-- <dependency id="cordova-plugin-add-swift-support" version="1.6.0" />-->
<dependency id="cordova-plugin-compat" version="^1.0.0" />
<dependency id="es6-promise-plugin" />

<!-- android -->
<platform name="android">
Expand All @@ -43,6 +42,7 @@
<source-file src="src/android/JSONHelper.java" target-dir="src/com/cowbell/cordova/geofence" />
<source-file src="src/android/LocalStorage.java" target-dir="src/com/cowbell/cordova/geofence" />
<source-file src="src/android/LocalStorageDBHelper.java" target-dir="src/com/cowbell/cordova/geofence" />
<source-file src="src/android/LocationProviderChangedReceiver.java" target-dir="src/com/cowbell/cordova/geofence"/>
<source-file src="src/android/Logger.java" target-dir="src/com/cowbell/cordova/geofence" />
<source-file src="src/android/Notification.java" target-dir="src/com/cowbell/cordova/geofence" />
<source-file src="src/android/ReceiveTransitionsIntentService.java" target-dir="src/com/cowbell/cordova/geofence" />
Expand All @@ -68,7 +68,12 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<receiver android:name="com.cowbell.cordova.geofence.LocationProviderChangedReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED"/>
</intent-filter>
</receiver>

</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
Expand Down Expand Up @@ -116,7 +121,8 @@

<!-- ios -->
<platform name="ios">
<hook type="after_plugin_install" src="hooks/add_swift_support.js" />
<hook type="after_plugin_add" src="hooks/install_prerequisites.js"/>
<hook type="after_plugin_add" src="hooks/add_swift_support.js" />
<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
<string>${EXECUTABLE_NAME} Would Like to Use Your Current Location Even In Background.</string>
</config-file>
Expand All @@ -133,11 +139,13 @@
<param name="ios-package" value="HWPGeofencePlugin"/>
</feature>
</config-file>
<header-file src="src/ios/Geo-Bridging-Header.h" />
<header-file src="src/ios/Geofence-Plugin-Bridging-Header.h" />
<source-file src="src/ios/GeofencePlugin.swift"/>
<source-file src="src/ios/SwiftData.swift"/>
<source-file src="src/ios/SwiftyJson.swift"/>

<framework src="libsqlite3.dylib"/>
<framework src="WebKit.framework" weak="true" />

<header-file src="src/ios/AppDelegate+Geofencing.h"/>
<source-file src="src/ios/AppDelegate+Geofencing.m"/>
<header-file src="src/ios/GeofenceHelper.h"/>
Expand Down
46 changes: 46 additions & 0 deletions src/android/LocationProviderChangedReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.cowbell.cordova.geofence;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.LocationManager;

/**
* Created by domingosgomes on 11/01/17.
*/
public class LocationProviderChangedReceiver extends BroadcastReceiver {
private String GpsPreferences = "GpsPreferences";
private String GpsSharePreferences = "GpsHasEnable";

@Override
public void onReceive(Context context, Intent intent) {
boolean isGpsEnabled;
if (intent.getAction().matches("android.location.PROVIDERS_CHANGED"))
{
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
isGpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
Boolean GpsHasEnable = getGpsState(context);
//Start your Activity if location was enabled:
if (isGpsEnabled && !GpsHasEnable) {
Logger.setLogger(new Logger(GeofencePlugin.TAG, context, false));
GeoNotificationManager manager = new GeoNotificationManager(context);
manager.loadFromStorageAndInitializeGeofences();
}
setGpsState(isGpsEnabled,context);
}
}

public void setGpsState(Boolean state, Context context){
SharedPreferences sharedPref = context.getSharedPreferences(GpsPreferences,Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(GpsSharePreferences, state);
editor.commit();
}

public Boolean getGpsState(Context context){
SharedPreferences sharedPref = context.getSharedPreferences(GpsPreferences,Context.MODE_PRIVATE);
Boolean gpsState = sharedPref.getBoolean(GpsSharePreferences,true);
return gpsState;
}
}
Binary file added src/android/libs/gson-2.3.jar
Binary file not shown.
18 changes: 0 additions & 18 deletions src/ios/AppDelegate+Geofencing.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,6 @@ - (BOOL) geofencing_application:(UIApplication *)application didFinishLaunchingW
return [self geofencing_application:application didFinishLaunchingWithOptions:launchOptions];
}

-(void) geofence_application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"Did Receive Local Notification Delegate - Geofence");

if(notification != nil && notification.userInfo && [notification.userInfo objectForKey:@"geofence.notification.data"]) {
NSDictionary *userInfo = notification.userInfo;
NSURL *siteURL = [NSURL URLWithString:[userInfo objectForKey:@"deeplink"]];

if(siteURL && [userInfo objectForKey:@"deeplink"] && ![[userInfo objectForKey:@"deeplink"] isEqualToString:@""]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[UIApplication sharedApplication] openURL:siteURL];
});
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"CDVLocalNotificationGeofence" object:notification];
}
[self geofence_application:application didReceiveLocalNotification:notification];
}

-(void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
Expand Down
9 changes: 9 additions & 0 deletions src/ios/Geofence-Plugin-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import <Cordova/CDV.h>
#import <Cordova/CDVAvailability.h>
#import <CoreLocation/CoreLocation.h>
#import "sqlite3.h"
#import "GeofenceHelper.h"
2 changes: 1 addition & 1 deletion src/ios/SwiftData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2148,4 +2148,4 @@ extension String {

return nsSt.stringByAppendingPathExtension(ext)
}
}
}
2 changes: 1 addition & 1 deletion src/ios/SwiftyJson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1362,4 +1362,4 @@ public func >=(lhs: NSNumber, rhs: NSNumber) -> Bool {
default:
return lhs.compare(rhs) != NSComparisonResult.OrderedAscending
}
}
}
Empty file modified src/windows/GeofenceComponent.winmd
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion src/windows/GeofenceProxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {

module.exports = {
initialize: function (success, fail, args, env) {
GeofenceComponent.GeofenceTrigger.register();
success && success();
Expand Down
Empty file modified src/windows/libs/Newtonsoft.Json.dll
100755 → 100644
Empty file.
Empty file modified src/wp8/GeofenceComponent.winmd
100755 → 100644
Empty file.
Empty file modified src/wp8/GeofencePlugin.cs
100755 → 100644
Empty file.
Empty file modified src/wp8/libs/Newtonsoft.Json.dll
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions tests/.jshintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"predef": [
"document",
Expand Down
69 changes: 69 additions & 0 deletions tests/hooks/fix-swift-paramedic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
var child_process = require('child_process'),
fs = require('fs'),
path = require('path');

module.exports = function(context) {
var COMMENT_KEY = /_comment$/,
CORDOVA_VERSION = process.env.CORDOVA_VERSION;

if (!process.env.FIX_PARAMEDIC) {
return;
}

run();

function run() {
var cordova_util = context.requireCordovaModule('cordova-lib/src/cordova/util'),
ConfigParser = CORDOVA_VERSION >= 6.0
? context.requireCordovaModule('cordova-common').ConfigParser
: context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'),
projectRoot = cordova_util.isCordova(),
platform_ios,
xml = cordova_util.projectConfig(projectRoot),
cfg = new ConfigParser(xml),
projectName = cfg.name(),
platform_ios = CORDOVA_VERSION < 5.0
? context.requireCordovaModule('cordova-lib/src/plugman/platforms')['ios']
: context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios'),
iosPlatformPath = path.join(projectRoot, 'platforms', 'ios'),
iosProjectFilesPath = path.join(iosPlatformPath, projectName),
xcconfigPath = path.join(iosPlatformPath, 'cordova', 'build.xcconfig'),
xcconfigContent,
projectFile,
xcodeProject,
bridgingHeaderPath;

projectFile = platform_ios.parseProjectFile(iosPlatformPath);
xcodeProject = projectFile.xcode;


var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection()),
config, buildSettings;

for (config in configurations) {
buildSettings = configurations[config].buildSettings;
buildSettings['SWIFT_VERSION'] = '2.3'
}
console.log('IOS project Swift Version changed to 2.3 ...');

projectFile.write();
}

function nonComments(obj) {
var keys = Object.keys(obj),
newObj = {},
i = 0;

for (i; i < keys.length; i++) {
if (!COMMENT_KEY.test(keys[i])) {
newObj[keys[i]] = obj[keys[i]];
}
}

return newObj;
}

function unquote(str) {
if (str) return str.replace(/^"(.*)"$/, "$1");
}
}
6 changes: 5 additions & 1 deletion tests/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geofence-test" version="0.5.0">
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geofence-test" version="0.6.0">
<name>Geofence plugin Tests</name>
<license>Apache 2.0</license>

<js-module src="tests.js" name="tests">
</js-module>

<platform name="ios">
<hook type="before_run" src="hooks/fix-swift-paramedic.js" />
</platform>
</plugin>
1 change: 1 addition & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

exports.defineAutoTests = function () {
var fail = function (done, reason) {
if (reason) {
Expand Down
Loading

0 comments on commit ab9a294

Please sign in to comment.