1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"deploymentTarget": "9"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as AudioToolbox from 'AudioToolbox';
|
||||
import * as UIKit from 'UIKit';
|
||||
import { Thread } from 'Foundation';
|
||||
|
||||
|
||||
/**
|
||||
* 震动
|
||||
* @param {number} duriation 震动时间单位ms,ios 13.+有用。
|
||||
*/
|
||||
export function vibrator(duriation : number):boolean {
|
||||
if (UTSiOS.available("iOS 13.0, *")) {
|
||||
let generator = new UIKit.UIImpactFeedbackGenerator(style = UIKit.UIImpactFeedbackGenerator.FeedbackStyle.medium)
|
||||
generator.prepare();
|
||||
let start = new Date().getTime();
|
||||
let end = start + duriation
|
||||
while(start<end){
|
||||
generator.impactOccurred(intensity = 0.5);
|
||||
Thread.sleep(forTimeInterval = 0.1)
|
||||
start = new Date().getTime();
|
||||
}
|
||||
}else{
|
||||
AudioToolbox.AudioServicesPlayAlertSound(AudioToolbox.kSystemSoundID_Vibrate)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user