Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to Swift 3 and add hasPermission method #2

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0012bfc
Adapt to Swift 3
Jan 17, 2017
d9f0fe1
Remove unneeded extension. Fix legacy variables
Jan 17, 2017
59d1721
Avoid use of Any in Dictionary
Jan 17, 2017
058a9de
Fix guard let with sequence expression
Jan 17, 2017
6aa3e3b
Fix guard let with sequence expression
Jan 17, 2017
65be572
Fix guard let with sequence expression
Jan 17, 2017
3b528db
Replace renamed fields and functions
Jan 17, 2017
a226652
Fix guard let with sequence expression
Jan 17, 2017
523dd38
Fix guard let with sequence expression
Jan 17, 2017
9b30274
Fix guard let with sequence expression
Jan 17, 2017
9a4efa5
Replace renamed fields and functions
Jan 17, 2017
bcdc342
Replace renamed fields and functions
Jan 18, 2017
60a306d
Replace renamed fields and functions
Jan 18, 2017
eac692f
Replace renamed fields and functions
Jan 18, 2017
76856a4
Replace renamed fields and functions
Jan 18, 2017
d02e764
Replace renamed fields and functions
Jan 18, 2017
6284e56
Replace renamed fields and functions
Jan 18, 2017
a0f064b
Replace renamed fields and functions
Jan 18, 2017
0262ba3
Replace renamed fields and functions
Jan 18, 2017
c043bec
Replace renamed fields and functions
Jan 18, 2017
727c435
Replace renamed fields and functions
Jan 18, 2017
337169c
Replace renamed fields and functions
Jan 18, 2017
ce0ccc5
Replace renamed fields and functions
Jan 18, 2017
631d5bb
Replace renamed fields and functions
Jan 18, 2017
d822b22
Replace renamed fields and functions
Jan 18, 2017
57c7fe4
Add function in js file
Jan 19, 2017
a8d9d8a
Bump cordova-plugin-add-swift-support version
Jan 19, 2017
fd541b3
Fix has permission function call
Jan 19, 2017
35a4c9e
Fix has permission function call
Jan 19, 2017
7757cca
Fix has permission function call
Jan 19, 2017
a11ed6b
Fix has permission function call
Jan 19, 2017
136b977
Add objc annotation to make methods accessible
Jan 19, 2017
d3d6a7e
Add permission request messages
natete Feb 23, 2017
60f9ad7
Update package.json
natete Jun 7, 2017
acf2091
Update package.json
natete Jun 7, 2017
e274c6a
Update package.json
natete Jun 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"build": "babel src/www -d .",
"clean": "cd tests/app && rimraf platforms plugins",
"test": "eslint src/permissionScope.js tests/tests.js",
"install": "npm run build && cd tests/app && cordova platform rm ios && cordova platform add ios",
"deploy": "cd tests/app && cordova run --device"
}
}
5 changes: 5 additions & 0 deletions permissionScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ types.forEach(function (type) {

exports.show = function (success, error) {
(0, _exec2.default)(success, error, 'PermissionScope', 'show');
};


exports.hasPermission = function (type, success, error) {
(0, _exec2.default)(success, error, 'PermissionScope', 'hasPermission', [ type ]);
};
29 changes: 27 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-permissionScope"
version="2.1.1">
version="2.1.2">
<name>PermissionScope</name>
<license>Apache 2.0</license>
<description>Cordova plugin to handle iOS permissions</description>
<keywords>cordova,phonegap,permission,permissionScope</keywords>

<platform name="ios">
<preference name="CONTACTS_USAGE_DESCRIPTION" default="This app needs contact access"/>
<config-file target="*-Info.plist" parent="NSContactsUsageDescription">
<string>$CONTACTS_USAGE_DESCRIPTION</string>
</config-file>

<preference name="CALENDAR_USAGE_DESCRIPTION" default="This app needs calendar access"/>
<config-file target="*-Info.plist" parent="NSCalendarsUsageDescription">
<string>$CALENDAR_USAGE_DESCRIPTION</string>
</config-file>

<preference name="BLUETOOTH_USAGE_DESCRIPTION" default="This app needs bluetooth access"/>
<config-file target="*-Info.plist" parent="NSBluetoothPeripheralUsageDescription">
<string>$BLUETOOTH_USAGE_DESCRIPTION</string>
</config-file>

<preference name="MICROPHONE_USAGE_DESCRIPTION" default="This app needs microphone access"/>
<config-file target="*-Info.plist" parent="NSMicrophoneUsageDescription">
<string>$MICROPHONE_USAGE_DESCRIPTION</string>
</config-file>

<preference name="MOTION_USAGE_DESCRIPTION" default="This app needs motion access"/>
<config-file target="*-Info.plist" parent="NSMotionUsageDescription">
<string>$MOTION_USAGE_DESCRIPTION</string>
</config-file>

<config-file target="config.xml" parent="/*">
<feature name="PermissionScope">
<param name="ios-package" value="PermissionScopePlugin" />
Expand All @@ -27,7 +52,7 @@
<source-file src="src/ios/PermissionScope/Structs.swift"/>
<source-file src="src/ios/PermissionScopePlugin.swift" />

<dependency id="cordova-plugin-add-swift-support" version="1.5.0"/>
<dependency id="cordova-plugin-add-swift-support" version="1.6.1"/>
</platform>

</plugin>
1 change: 1 addition & 0 deletions src/ios/PermissionScope-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#import "PermissionScope.h"
#import <UIKit/UIKit.h>
28 changes: 14 additions & 14 deletions src/ios/PermissionScope/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ extension String {
}
}

extension SequenceType {
/**
Returns the first that satisfies the predicate includeElement, or nil. Similar to `filter` but stops when one element is found. Thanks to [bigonotetaking](https://bigonotetaking.wordpress.com/2015/08/22/using-higher-order-methods-everywhere/)

- parameter includeElement: Predicate that the Element must satisfy.

- returns: First element that satisfies the predicate, or nil.
*/
func first(@noescape includeElement: Generator.Element -> Bool) -> Generator.Element? {
for x in self where includeElement(x) { return x }
return nil
}
}
//extension Sequence {
// /**
// Returns the first that satisfies the predicate includeElement, or nil. Similar to `filter` but stops when one element is found. Thanks to [bigonotetaking](https://bigonotetaking.wordpress.com/2015/08/22/using-higher-order-methods-everywhere/)
//
// - parameter includeElement: Predicate that the Element must satisfy.
//
// - returns: First element that satisfies the predicate, or nil.
// */
// func first(_ includeElement: (Iterator.Element) -> Bool) -> Iterator.Element? {
// for x in self where includeElement(x) { return x }
// return nil
// }
//}

extension Optional {
/// True if the Optional is .None. Useful to avoid if-let.
var isNil: Bool {
if case .None = self {
if case .none = self {
return true
}
return false
Expand Down
Loading