Content-Length: 401713 | pFad | http://github.com/NativeScript/plugins/commit/13ba4dc63b6b1408d89d40f15f37a44ee38cecd7

29 fix(haptics): remove uname usage and simplify supported condition · NativeScript/plugins@13ba4dc · GitHub
Skip to content

Commit 13ba4dc

Browse files
committed
fix(haptics): remove uname usage and simplify supported condition
closes #596
1 parent 6efa4cc commit 13ba4dc

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

Diff for: packages/haptics/README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Thanks to [Eddy Verbruggen](EddyVerbruggen) for providing [nativescript-taptic-e
1414
* [Use @nativescript/haptics](#use-nativescripthaptics)
1515
* [API](#api)
1616
* [isSupported()](#issupported)
17-
* [is6SAnd6SPlusSupported()](#is6sand6splussupported)
1817
* [selection()](#selection)
1918
* [notifcation()](#notification)
2019
* [impact()](#impact)
@@ -44,14 +43,6 @@ isHapticsSupported: boolean = Haptics.isSupported()
4443
```
4544
Checks if haptics is supported on the device.
4645

47-
---
48-
### is6SAnd6SPlusSupported()
49-
```ts
50-
isHapticsSupported: boolean = Haptics.is6SAnd6SPlusSupported()
51-
```
52-
53-
Checks if Haptics is supported on iOS.
54-
5546
---
5647
### selection()
5748

@@ -97,7 +88,7 @@ There are 3 impact types:
9788
To use the haptics fallbacks, check if there is support:
9889

9990
```ts
100-
if (!Haptics.isSupported() && Haptics.is6SAnd6SPlusSupported()) {
91+
if (!Haptics.isSupported()) {
10192
// use HapticsFallback
10293
}
10394
```

Diff for: packages/haptics/index.ios.ts

+1-30
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ let generatorSelection: UISelectionFeedbackGenerator;
99

1010
export class Haptics {
1111
static isSupported() {
12-
return Utils.SDK_VERSION >= 10.0 && deviceInfo().version > 8;
13-
}
14-
15-
static is6SAnd6SPlusSupported() {
16-
const details = deviceInfo();
17-
return Utils.SDK_VERSION >= 10.0 && (details.name?.indexOf('iPhone8,1') > -1 || details.name?.indexOf('iPhone8,2') > -1);
12+
return Utils.SDK_VERSION >= 10.0;
1813
}
1914

2015
static notification(type?: HapticNotificationType) {
@@ -94,27 +89,3 @@ export class HapticsFallback {
9489
AudioServicesPlaySystemSound(1521);
9590
}
9691
}
97-
98-
function deviceInfo() {
99-
const _SYS_NAMELEN: number = 256;
100-
101-
const buffer: any = interop.alloc(5 * _SYS_NAMELEN);
102-
// @ts-expect-error
103-
uname(buffer);
104-
let name: string = NSString.stringWithUTF8String(buffer.add(_SYS_NAMELEN * 4)).toString();
105-
106-
// Get machine name for Simulator
107-
if (name === 'x86_64' || name === 'i386' || name === 'arm64') {
108-
name = NSProcessInfo.processInfo.environment.objectForKey('SIMULATOR_MODEL_IDENTIFIER');
109-
}
110-
111-
const parts = name.toLowerCase().split('iphone');
112-
let version: number;
113-
if (parts && parts.length > 1) {
114-
version = parseInt(parts[1]);
115-
}
116-
return {
117-
name,
118-
version: isNaN(version) ? 0 : version,
119-
};
120-
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/plugins/commit/13ba4dc63b6b1408d89d40f15f37a44ee38cecd7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy