GithubHelp home page GithubHelp logo

hyfone / countly-sdk-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from countly/countly-sdk-cordova

0.0 2.0 0.0 7 MB

Countly SDK for Icenium and Phonegap

License: MIT License

JavaScript 75.18% CSS 1.62% HTML 1.13% Java 15.50% Objective-C 6.56%

countly-sdk-js's Introduction

Phonegap and Cordova SDK for Countly

Countly is an innovative, real-time, open source mobile analytics and push notifications platform. It collects data from mobile devices, and visualizes this information to analyze mobile application usage and end-user behavior. There are two parts of Countly: the server that collects and analyzes data, and mobile SDK that sends this data. Both parts are open source with different licensing terms.

This repository includes the SDK for Phonegap and Icenium. You also need Countly server - either hosted on cloud, or installed on-premise as Community Edition or Enterprise Edition

Using SDK

cordova create CountlyDemo ly.count.demo CountlyDemo
cd CountlyDemo

//adding plugins
{
	//if you are using countly push notification
	cordova plugin add org.apache.cordova.device
	cordova plugin add https://github.com/phonegap-build/PushPlugin.git
}

//countly core plugin
cordova plugin add https://github.com/Countly/countly-sdk-js.git

//add platform
cordova platform add android
cordova platform add ios

//!important make sure you build it with cordova
// as cordova links folders very well
cordova build android
cordova build ios

//run the app directly
cordova run android
cordova run ios

//or open the source in Xcode, or eclipse

With meteor app

meteor add countly:countly-sdk-js

In your index.html, use the following lines:

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="Countly.js"></script> <!-- no longer required in cordova 3.5 and above, it is auto added -->

Implementation

Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of cloud.count.ly in case you have your own server.

//initialize
Countly.init("https://cloud.count.ly","App_Key");

//countly push notification
Countly.initMessaging({"messageMode": Countly.messagingMode.TEST, "projectId": "881000050249"});

// example for sending basic custom event
var events = {"eventName":"basic_event","eventCount":1};
Countly.sendEvent(events);

// example for event with sum
var events = {"eventName":"event_sum","eventCount":1,"eventSum":"0.99"};
Countly.sendEvent(events);

// example for event with segment
var events = {"eventName":"event_segment","eventCount":1};
events.segments = {"Country" : "Turkey", "Age" : "28"};
Countly.sendEvent(events);

// example for event with segment and sum
var events = {"eventName":"event_segment_sum","eventCount":1,"eventSum":"0.99"};
events.segments = {"Country" : "Turkey", "Age" : "28"};
Countly.sendEvent(events);

// example for setUserData - Enterprise Edition only
var options = {};
options.name = "Trinisoft Technologies";
options.username = "trinisofttechnologies";
options.email = "[email protected]";
options.org = "Trinisoft Technologies Pvt. Ltd.";
options.phone = "+91 812 840 2946";
options.picture = "http://www.trinisofttechnologies.com/images/logo.png";
options.picturePath = "";
options.gender = "Male";
options.byear = 1989;
Countly.setUserData(options);

// example for setLoggingEnabled
Countly.setLoggingEnabled();

//example to start and stop Countly
Countly.start();
Countly.stop();

Troubleshooting

NSPersistentStoreCoordinator with a nil model'

In this case got to https://github.com/Countly/countly-sdk-js/tree/master/src/ios/sdk Drag and drop "Countly.xcdatamodeld" folder into your plugins folder. and build it using Xcode.

If you are facing any difficulty in implementing procedures above, please report an issue or directly email me at [email protected].

Acknowledgements

This SDK was initially written by Panteon Technologies ([email protected]).
It's now maintained by Trinisoft Technologies ([email protected]).

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.