Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics - cordova_not_available #1353

Closed
jgw96 opened this issue Apr 10, 2017 · 13 comments
Closed

Google Analytics - cordova_not_available #1353

jgw96 opened this issue Apr 10, 2017 · 13 comments

Comments

@jgw96
Copy link

jgw96 commented Apr 10, 2017

From @mikeborozdin on April 9, 2017 17:19

Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
An error in the browser screen:

Runtime Error
Uncaught (in promise): cordova_not_available

Expected behavior:
No error. I should be able to see my application

Steps to reproduce:

  1. Create a new Ionic 3 project (I used ionic start --v3 myApp)
  2. Follow the steps from https://ionicframework.com/docs/native/google-analytics/
    2.1 ionic plugin add cordova-plugin-google-analytics
    2.2 npm install --save @ionic-native/google-analytics
    2.3. Add the sample snippet code
    2.4 Run ionic serve

Related code:

platform.ready().then(() => {
      this.ga.startTrackerWithId(myCode).then(() => {
        statusBar.styleDefault();
        splashScreen.hide();
      });
    });

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Xcode 8.3 Build version 8E162

Copied from original issue: ionic-team/ionic-framework#11139

@dtaalbers
Copy link

Just throwing in my 2 cents. Cordova is only available on devices. If you want to use native functionalities in your browser you can mock them with ionic native 3.x.x.

@royipressburger
Copy link

royipressburger commented Apr 10, 2017

@dtaalbers I think the problem with this is that he gets cordova_not_available as an error in the console, I get the same error. usually plugins throw warnings.

@dtaalbers
Copy link

Ah in that case, ignore me! I agree that shouldn't be an error.

@ihadeed
Copy link
Collaborator

ihadeed commented May 17, 2017

Make sure you wrap your code with platform.ready().then( .. ). If you are running this as soon as the app starts, I suggest waiting a second or so before executing the code.

@ihadeed ihadeed closed this as completed May 17, 2017
@boboldehampsink
Copy link

I'm seeing this with google analytics while wrapped in platform.ready. Catching the promise fixes it, but i only expect a warning instead of an exception.

@peterpan666
Copy link

Seeing this too.

I'm in platform ready on the browser, no reason to throw an exception, really annoying...

Could this issue be reopened @ihadeed ?

@Ludplay
Copy link

Ludplay commented Dec 29, 2017

Same here. Very weird. It happens just with Analytics.

@Ludplay
Copy link

Ludplay commented Dec 29, 2017

However, as @boboldehampsink has said, setting a simple catch() fixes it. But it's worth the record.

@cnd5041
Copy link

cnd5041 commented Nov 14, 2018

@ihadeed can this be reopened? I am seeing the issue when wrapping in platform.ready on ionic serve.

@boboldehampsink do you mean a catch on the startTrackerWithId? Even with that I'm not seeing any tracking.
Thanks.

@cSparkle
Copy link

@ihadeed, I would also like to request that this be reopened. I'm facing this issue as well even after wrapping in platform.ready() and including a catch().

@2-towns
Copy link

2-towns commented Jun 19, 2019

I have also the problem with Ionic 4

@sabi1981
Copy link

The same problem on @ionic/angular 5.3.2 ... is there any solution after 3 years?

@dwasyluk
Copy link

Same issue here, the docs for this library say it can be used in browser to why is cordova_not_available even an issue if its supposed to be supported by browser? https://ionicframework.com/docs/native/google-analytics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests