2015-11-08 144 views
0

我建立一個web應用程序,它涉及一種用於移動設備搖晃事件的檢測:繞道「ondevicemotion」棄用警告在Chrome

if (this.hasDeviceMotion) { window.addEventListener('devicemotion', this, false); } 

我使用shake.js plugin亞歷克斯·吉布森。

當Chrome桌面瀏覽器中我得到這個警告的測試我的應用程序:

The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

在這個環節有這樣的文字:

We want to start applying the concepts in https://w3c.github.io/webappsec/specs/powerfulfeatures/ to features that have already shipped and which do not meet the (new, not present at the time) requirements. We want to start by requiring secure origins for these existing features: Device motion/orientation EME Fullscreen Geolocation getUserMedia()...

即使它當前已過時的桌面Chrome瀏覽器,瞭解Mountain View中的傢伙我相信它很快就會在移動Chrome和Android Webview上被棄用。

我的應用託管在沒有安全連接的服務器上,只是HTTP。有沒有辦法繞過這個警告,並在我的應用程序中使用HTTP連接進行震動檢測?

回答

0

無法在不安全的來源處繞過此警告,並且您是正確的,它將在我們能夠自動更新的所有平臺上棄用。現在這只是一個貶低警告,並沒有被推到一個完整的刪除呢。我們沒有時間表來確定它何時會被刪除。

+0

非常感謝你詳細解答! – Igal

+2

問題:爲什麼設備定位被認爲是「強大功能」,爲什麼會被棄用?當然不僅僅是通過消除有用的但不危險的功能來被動地強迫人們進入HTTPS ...... –

1

繞過棄用的最佳方式是將您的應用程序移至HTTPS。

許多瀏覽器都會棄用普通的HTTP,以使網絡更安全。您應該遵循這一趨勢並使您的應用程序支持HTTPS。這並不難,有免費的SSL證書來(Let's Encrypt)。