@capacitor/haptics 1.0.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.1.1...@capacitor/haptics@1.1.2) (2021-10-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.1.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.1.0...@capacitor/haptics@1.1.1) (2021-10-13)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
23
+
24
+
25
+
26
+
27
+
28
+ # [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.3...@capacitor/haptics@1.1.0) (2021-09-27)
29
+
30
+
31
+ ### Features
32
+
33
+ * **haptics:** Implement duration for vibration ([#618](https://github.com/ionic-team/capacitor-plugins/issues/618)) ([78e6b68](https://github.com/ionic-team/capacitor-plugins/commit/78e6b6886fa50318b1bfbe229e7318e521e3c245))
34
+
35
+
36
+
37
+
38
+
39
+ ## [1.0.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.2...@capacitor/haptics@1.0.3) (2021-09-01)
40
+
41
+ **Note:** Version bump only for package @capacitor/haptics
42
+
43
+
44
+
45
+
46
+
47
+ ## [1.0.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.1...@capacitor/haptics@1.0.2) (2021-06-23)
48
+
49
+ **Note:** Version bump only for package @capacitor/haptics
50
+
51
+
52
+
53
+
54
+
6
55
  ## [1.0.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.0...@capacitor/haptics@1.0.1) (2021-06-09)
7
56
 
8
57
  **Note:** Version bump only for package @capacitor/haptics
@@ -7,10 +7,10 @@ Pod::Spec.new do |s|
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.license = package['license']
10
- s.homepage = package['repository']['url']
10
+ s.homepage = 'https://capacitorjs.com'
11
11
  s.author = package['author']
12
- s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
12
+ s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}', 'haptics/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '12.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
package/README.md CHANGED
@@ -169,9 +169,9 @@ For example, call this when a user has lifted their finger from a control
169
169
 
170
170
  #### VibrateOptions
171
171
 
172
- | Prop | Type | Description | Default | Since |
173
- | -------------- | ------------------- | ---------------------------------------------------------------- | ---------------- | ----- |
174
- | **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. Not supported in iOS. | <code>300</code> | 1.0.0 |
172
+ | Prop | Type | Description | Default | Since |
173
+ | -------------- | ------------------- | ----------------------------------------------------------------------------- | ---------------- | ----- |
174
+ | **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. Not supported in iOS 12 and older. | <code>300</code> | 1.0.0 |
175
175
 
176
176
 
177
177
  ### Enums
package/dist/docs.json CHANGED
@@ -196,7 +196,7 @@
196
196
  "name": "since"
197
197
  }
198
198
  ],
199
- "docs": "Duration of the vibration in milliseconds.\n\nNot supported in iOS.",
199
+ "docs": "Duration of the vibration in milliseconds.\n\nNot supported in iOS 12 and older.",
200
200
  "complexTypes": [],
201
201
  "type": "number"
202
202
  }
@@ -105,7 +105,7 @@ export interface VibrateOptions {
105
105
  /**
106
106
  * Duration of the vibration in milliseconds.
107
107
  *
108
- * Not supported in iOS.
108
+ * Not supported in iOS 12 and older.
109
109
  *
110
110
  * @default 300
111
111
  * @since 1.0.0
package/dist/plugin.js CHANGED
@@ -127,5 +127,5 @@ var capacitorHaptics = (function (exports, core) {
127
127
 
128
128
  return exports;
129
129
 
130
- }({}, capacitorExports));
130
+ })({}, capacitorExports);
131
131
  //# sourceMappingURL=plugin.js.map
@@ -1,5 +1,6 @@
1
1
  import AudioToolbox
2
2
  import UIKit
3
+ import CoreHaptics
3
4
 
4
5
  @objc public class Haptics: NSObject {
5
6
 
@@ -34,4 +35,39 @@ import UIKit
34
35
  @objc public func vibrate() {
35
36
  AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
36
37
  }
38
+
39
+ @objc public func vibrate(_ duration: Double) {
40
+ if #available(iOS 13, *) {
41
+ if CHHapticEngine.capabilitiesForHardware().supportsHaptics {
42
+ do {
43
+ let engine = try CHHapticEngine()
44
+ try engine.start()
45
+ engine.resetHandler = { [] in
46
+ do {
47
+ try engine.start()
48
+ } catch {
49
+ self.vibrate()
50
+ }
51
+ }
52
+ let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0)
53
+ let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
54
+
55
+ let continuousEvent = CHHapticEvent(eventType: .hapticContinuous,
56
+ parameters: [intensity, sharpness],
57
+ relativeTime: 0.0,
58
+ duration: duration)
59
+ let pattern = try CHHapticPattern(events: [continuousEvent], parameters: [])
60
+ let player = try engine.makePlayer(with: pattern)
61
+
62
+ try player.start(atTime: 0)
63
+ } catch {
64
+ vibrate()
65
+ }
66
+ } else {
67
+ vibrate()
68
+ }
69
+ } else {
70
+ vibrate()
71
+ }
72
+ }
37
73
  }
@@ -56,8 +56,9 @@ public class HapticsPlugin: CAPPlugin {
56
56
  }
57
57
 
58
58
  @objc public func vibrate(_ call: CAPPluginCall) {
59
+ let duration = call.getDouble("duration", 300)/1000
59
60
  DispatchQueue.main.async {
60
- self.implementation.vibrate()
61
+ self.implementation.vibrate(duration)
61
62
  }
62
63
  call.resolve()
63
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/haptics",
3
- "version": "1.0.1",
3
+ "version": "1.1.2",
4
4
  "description": "The Haptics API provides physical feedback to the user through touch or vibration.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -41,12 +41,13 @@
41
41
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
42
  "clean": "rimraf ./dist",
43
43
  "watch": "tsc --watch",
44
- "prepublishOnly": "npm run build"
44
+ "prepublishOnly": "npm run build",
45
+ "publish:cocoapod": "pod trunk push ./CapacitorHaptics.podspec --allow-warnings"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@capacitor/android": "^3.0.0",
48
49
  "@capacitor/core": "^3.0.0",
49
- "@capacitor/docgen": "0.0.16",
50
+ "@capacitor/docgen": "0.0.18",
50
51
  "@capacitor/ios": "^3.0.0",
51
52
  "@ionic/eslint-config": "^0.3.0",
52
53
  "@ionic/prettier-config": "~1.0.1",
@@ -78,5 +79,5 @@
78
79
  "publishConfig": {
79
80
  "access": "public"
80
81
  },
81
- "gitHead": "4307cd7af743bd3ae1942d892982542b0ccd8599"
82
+ "gitHead": "eadbffd4bf9f0859bd301a639ab4e0c3337ea8db"
82
83
  }