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
MySQL is a database that I like very much. Today,...
Recently, a new requirement "front-end cache...
html4: Copy code The code is as follows: <form...
Using DOSBox, you can simulate DOS under Windows ...
Table of contents Starting from type judgment Str...
Overview of Alibaba Cloud Security Group Sharing ...
1. Vector Map Vector graphics use straight lines ...
Preface Although the holiday is over, it shows up...
If you want to become a Linux master, then master...
Table of contents Same Origin Policy Ajax request...
Table of contents illustrate 1. Enable Docker rem...
Table of contents Preface 1. Introduction to one-...
In the hive installation directory, enter the con...
I have been in contact with MGR for some time. Wi...
Table of contents 1. Test environment 1.1 Install...