emm*_*ose 2 cordova ionic-framework
我正在接管Cordova / Ionic项目。我以前从未与Cordova或Ionic一起工作过,所以我是该领域的初学者。但是,我已经和Node一起工作了几年,所以我对此最了解。
一个简单的开始任务,我需要添加Appsee:
https://www.appsee.com/docs/ios/ionic
这部分很简单:
In case you're using TypeScript (default in ionic 2 and ionic 3) place the following line under the imports:
declare var Appsee:any;
Run Code Online (Sandbox Code Playgroud)
我放在这个文件中:
./src/app/app.component.ts
但是这一部分不太明显:
Call the following method when your app starts, preferably when the deviceready event fires:
Appsee.start("YOUR API KEY");
Run Code Online (Sandbox Code Playgroud)
所以我运行grep来查找deviceready在哪里:
grep -iR "deviceready" * | grep -v node_modules
www/build/vendor.js: * resolve when Cordova triggers the `deviceready` event.
www/build/vendor.js: // prepare a custom "ready" for cordova "deviceready"
www/build/vendor.js: doc.addEventListener('deviceready', function () {
www/build/vendor.js: // 3) cordova deviceready event triggered
www/build/vendor.js: var deviceReady = new Promise(function (resolve, reject) {
www/build/vendor.js: document.addEventListener("deviceready", function () {
www/build/vendor.js: var deviceReadyDone = deviceReady.catch(function () {
www/build/vendor.js: return deviceReadyDone.then(function () {
www/build/vendor.js: document.addEventListener('deviceready', function () {
www/build/vendor.js: console.log("Ionic Native: deviceready event fired after " + (Date.now() - before) + " ms");
www/build/vendor.js: console.warn("Ionic Native: deviceready did not fire within " + DEVICE_READY_TIMEOUT + "ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.");
Run Code Online (Sandbox Code Playgroud)
因此,我只能在build文件夹中看到“ deviceready” 。我认为我应该避免编辑其中的任何内容build?难道不是Ionic / Cordova所产生的东西吗?
我在哪里向deviceready注册东西?
如果我运行:
ionic info
Run Code Online (Sandbox Code Playgroud)
我得到:
[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : none
Ionic Framework : ionic-angular 3.6.0
System:
ios-deploy : 1.9.2
Node : v6.5.0
npm : 3.10.3
OS : OS X El Capitan
Xcode : Xcode 7.3.1 Build version 7D1014
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Run Code Online (Sandbox Code Playgroud)
我很乐意遵循其他地方的指示。
您应该使用Platform在IONIC中的app.component.ts中获取设备就绪事件。
从“ ionic-angular”导入{Platform};
在构造函数中添加platform.ready()方法,如下所示
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready.
// Here you can do any higher level native things you might need.
Appsee.start("YOUR API KEY");
statusBar.styleDefault();
splashScreen.hide();
});
Run Code Online (Sandbox Code Playgroud)
}
设备/平台准备就绪时将触发该事件。 这是文档
| 归档时间: |
|
| 查看次数: |
2507 次 |
| 最近记录: |