簡體   English   中英

在 ionic 4 應用程序中使用 web sdk 插件

[英]Use web sdk plugin in ionic 4 application

我有一個問題。 我想在我的離子應用程序中使用這個 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上使用。 有一些想法嗎? 提前謝謝

我是在 Countly 工作的開發人員之一。

您是否想在您的 Ionic 應用程序中使用 Web SDK? 它的主要用途是用於網頁而不是移動應用程序。

對於 Ionic 移動(Android 和 iOS)應用程序,我們推薦我們的“Cordova SDK”。

為了更好地理解如何在您的應用程序中使用我們的 SDK,請查看我們的文檔示例應用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM