Giter VIP home page Giter VIP logo

google-app-indexing-cordova's Introduction

NOT MAINTAINED

This package is not actively maintained and should not be used anymore.


Google App Indexing for Cordova/Ionic apps (Android only)

Further information on App Indexing: https://developers.google.com/app-indexing

Deeplinking first!

Be sure, that you have deeplinking enabled in your android app! I recommend you check out this plugin: https://github.com/EddyVerbruggen/Custom-URL-scheme

Installation

In your Cordova application do:

cordova plugin add google-app-indexing-cordova`

For Ionic:

ionic plugin add google-app-indexing-cordova`

Usage

When you add the plugin, there is a global AppIndexing object available, after cordova has loaded. This object has two methods: startView and endView with following signatures:

AppIndexing.startView(title, description, webPath, androidPath, success, error)

and

AppIndexing.endView(title, description, webPath, androidPath, success, error)

Whenever a user of your app starts viewing content in your app, just call the startView method, and when they leave the page call endView with exactly the same arguments.

Note: I think, Google is measuring the time the customer stays on that page to prevent that you simply push all of your content to the App Indexing. It can lead to your app not being indexed at all, if they see such behaviour.

webPath and androidPath

If you're confused about the two paths, please read on https://developers.google.com/app-indexing first. The webPath is your content accessible via the web (e.g. http://example.com/path/to/some-content). Whereas the androidPath is the deeplink to your android app in the style of android-app://{app package identifier}/{scheme}/{path}} (e.g. android-app://de.example.com/https/path/to/some-content). Ideally the path should be the same for web and deeplink, but that's up to you.

Got questions?

Don't hesitate to open a issue or tweet me @eneskaya

google-app-indexing-cordova's People

Contributors

eneskaya avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

google-app-indexing-cordova's Issues

window.AppIndexing is undefined

To use this plugin I had to use the following code in a controller (for definition):

  function definePluginGlobal() {
    var exec = window.cordova.exec;

    function AppIndexing() {}

    AppIndexing.prototype.startView = function(title, description, webPath, androidPath, success, error) {
      var arg0 = [
        title,
        description,
        webPath, // The path for the web content
        androidPath // The path for the android app deeplink
      ];

      exec(success, error, "AppIndexing", "startView", arg0);
    };

    AppIndexing.prototype.endView = function(title, description, webPath, androidPath, success, error) {
      var arg0 = [
        title,
        description,
        webPath, // The path for the web content
        androidPath // The path for the android app deeplink
      ];

      exec(success, error, "AppIndexing", "endView", arg0);
    };

    window.AppIndexing = new AppIndexing();
  }

In general I use the same code from www/google-app-indexing.js, I just replaced var exec = require('cordova/exec'); on var exec = window.cordova.exec

Cordova can't build android

``...
:compileDebugShaders

:generateDebugAssets
:mergeDebugAssets

:transformClassesWithDexForDebug
FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.89 secs
Error: /home/oangelo/fisica/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova build android (exit code 1).``

Ask

Do you have example how to use this plugin? how it works?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.