Recently, I made a function similar to shake, using shake.js. However, the shake function can be triggered in versions before ios13.3, and later versions need to be compatible. It is necessary to create a pop-up box that users can click manually so that users can authorize permissions for actions and directions. (https protocol is required) <van-popup v-model="isTip" class="popInfo" :close-on-click-overlay="false"> <div class="mainBody"> <h3 class="systemTip">Warm Tips</h3> <div class="confirm"> Since the iOS system needs to manually obtain permission to access actions and directions, to ensure the normal progress of the game, please click Allow in the access prompt. </div> </div> <button class="bottomButton" @click="handleInit"> Got it</button> </van-popup> shake.js //Introduce shake.js created(){ this.initShake() const isAction = JSON.parse(localStorage.getItem('getAction')) var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("like mac os x") > 0) { var reg = /os [\d._]*/gi ; var verinfo = ua.match(reg); var version = (verinfo+"").replace(/[^0-9|_.]/ig,"").replace(/_/ig,"."); if (parseFloat(version) >= 13.3 && !isAction){ localStorage.setItem("getAction",true) this.isTip = true } } }, methods:{ initShake(){ this.myShakeEvent = new Shake({ threshold: 15, // shake threshold timeout: 1000 // event frequency, optional value}); this.myShakeEvent.start(); window.addEventListener('shake', xx); }, handleInit(){ this.isTip = false this.ios13granted() }, ios13granted() { if (typeof DeviceMotionEvent.requestPermission === 'function') { DeviceMotionEvent.requestPermission().then(permissionState => { if (permissionState === 'granted') { this.initShake() //Shake} else if(permissionState === 'denied'){// The link you opened does not begin with https alert("The current IOS system denies access to actions and directions. Please exit WeChat and re-enter the event page to obtain permissions. Or directly click on the lottery bucket to participate in the event") } }).catch((error) => { alert("Requesting device orientation or motion access requires user gestures to prompt") }) } else { // Handle regular non-iOS 13+ device alert("Handle regular non-iOS 13+ devices") } }, } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of nginx optimization in high concurrency scenarios
>>: What to do if you forget the initial password of MySQL on MAC
Later, I also added how to use Jupyter Notebook i...
1. First install node, express, express-generator...
Table of contents 1. Introduction 2. Basic Concep...
Table of contents Overview Implementation Protect...
MySQL Bin log data recovery: accidentally delete ...
History of HTML development: HTML means Hypertext...
1. Install and use Docer CE This article takes Ce...
Table of contents JavaScript Objects 1. Definitio...
Table of contents 1. New usage of watch 1.1. Watc...
/****************** * Kernel debugging technology...
Hexadecimal code table of various colors [Part 1] ...
The steps for configuring Tomcat in IDEA 2020 are...
The function has been implemented a long time ago...
The previous article introduced the MySql multi-c...
Preface Learn to create a file system on your sys...