Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

javascript - firebase analytics.logEvent doesn't work in android 5 webview

I'm using FireBase analytics in my website. as their documentation says, I have inserted the following codes at the end of <body>:

<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-analytics.js"></script>

<script>
var firebaseConfig = {
    apiKey: "...",
    authDomain: "...",
    projectId: "...",
    storageBucket: "...",
    messagingSenderId: "...",
    appId: "...",
    measurementId: "..."
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const analytics = firebase.analytics();

and then I use analytics.logEvent(...); in my javascript code to log events. it works fine in chrome for example, but I just tested my site in android webview on a device with android 5.1 and my javascript gets stuck at this line: analytics.logEvent(...); and the codes after that doesn't run.

I can see this error in the console:

com.android.browser E/browser: Console: Uncaught TypeError: Cannot read property 'logEvent' of undefined https://example.com/document.js:366

what's the problem?

question from:https://stackoverflow.com/questions/65934779/firebase-analytics-logevent-doesnt-work-in-android-5-webview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...