ETENG-OSP / xgpush-cordova

腾讯信鸽推送 for Cordova
http://xg.qq.com/
MIT License
79 stars 38 forks source link

Promise is not defined #10

Closed xifengzhu closed 8 years ago

xifengzhu commented 9 years ago

Uncaught ReferenceError: Promise is not defined, error: plugins/cordova-plugin-xgpush/www/xgpush.js, Line: 1 Android

gengen1988 commented 9 years ago

先装这个插件 https://github.com/vstirbu/PromisesPlugin

xifengzhu commented 9 years ago

我看到这个插件在cordova-plugin-xgpush 里面有声明依赖,而且我装好cordova-plugin-xgpush这个之后发现https://github.com/vstirbu/PromisesPlugin 这个也被安装好了。

是需要有个安装先后顺序的问题么?

gengen1988 commented 9 years ago

确实是顺序的问题

我测了一下,依赖的插件加载的 js 的比原有插件的 js 要晚,所以 Promise Polyfill 没执行,导致在比较老的手机上用不了 Promise

暂时的解决方法是在项目里的 config.xml 里,按照如下顺序放置插件:

<plugin name="es6-promise-plugin" spec="~3.0.2" />
<plugin name="cordova-plugin-xgpush" spec="https://github.com/gengen1988/xgpush-cordova.git">
    <variable name="ACCESS_ID" value="你的 ACCESS ID" />
    <variable name="ACCESS_KEY" value="你的 ACCESS KEY" />
</plugin>

这个方法在 coolpad 8705 (原生不支持 Promise)上测试可行

xifengzhu commented 9 years ago

谢谢,我去试试。

gengen1988 commented 8 years ago

已经内置了 Promise polyfill,不会有这样的问题了