1

我有一个问题。我想在我的 ionic 应用程序中使用这个 sdk:https: //support.count.ly/hc/en-us/articles/360037441932-Web-analytics-JavaScript-#using-the-web-sdk-in-webview。我使用 ionic 版本 4,所以我不能使用他们的插件,因为只与 ionic 2 兼容。问题是我如何在我的组件中使用这个插件?我到目前为止所做的:

1. npm install countly-sdk-web
2. I modified index.html file to add the init :
<script type='text/javascript'>

// Some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];

// Provide your app key that you retrieved from Countly dashboard
Countly.app_key = "111";

// Provide your server IP or name. Use try.count.ly or us-try.count.ly
// or asia-try.count.ly for EE trial server.
// If you use your own server, make sure you have https enabled if you use
// https below.
Countly.url = "https://try.count.ly";

// Start pushing function calls to queue
// Track sessions automatically (recommended)
Countly.q.push(['track_sessions']);

//track web page views automatically (recommended)
Countly.q.push(['track_pageview']);

// Load Countly script asynchronously
(function() {
  var cly = document.createElement('script'); cly.type = 'text/javascript';
  cly.async = true;
  // Enter url of script here (see below for other option)
  cly.src = 'https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/lib/countly.min.js';
  cly.onload = function(){Countly.init()};
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();

没有错误,因此启动了 sdk。但是不知道怎么用.component.ts。有什么想法吗?提前谢谢

4

1 回答 1

0

我是在 Countly 工作的开发人员之一。

您是否想在 Ionic 应用程序中使用 Web SDK?它的主要用途是网页而不是移动应用程序。

对于 Ionic 移动(Android 和 iOS)应用程序,我们推荐我们的“Cordova SDK”。

为了更好地了解如何在您的应用程序中使用我们的 SDK,请查看我们的文档示例应用程序

于 2020-09-14T20:26:19.757 回答