Plugins Cordova não rodam no Ionic View

Estava desenvolvendo quando ocorreu um problema com o Ionic View no iOS. Ele não estava rodando como deveria. O SQLite não estava funcionando no iOS, mas no Android sim.

Buscando na Web descobri a solução postada pelo próprio time do Ionic Framework:

EDIT: To anyone else I’ve linked to this comment, this is a small workaround for the issue of plugins not working correctly in View. Cordova doesn’t load immediately in View, so Ionic’s check for isWebView to determine if it should wait for the Cordova deviceready event returns false and things likeionic.Platform.ready() execute immediately, which is often before plugins and Cordova have had a chance to initialize.

So if you guys aren’t adverse to a small hack, adding <script>window.phonegap = {}</script> to your<head> before Ionic loads should force it to wait for the deviceready event without stepping on Cordova’s toes once it does load. Much simpler than writing $timeout everywhere.

Simplesmente coloquei a seguinte linha antes dos css e scripts no www/index.html:

<script>window.phonegap = {}</script>

Fiz o upload pro Ionic View e resolveu o problema!

Espero que também possam ser ajudados por isso.


Posted

in

by

Tags: