Skip to content

isabella232/countly-sdk-unity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Countly Unity SDK

We're hiring: Countly is looking for full stack devs, devops and growth hackers (remote work). Click this link for job description

What's Countly?

Countly is an innovative, real-time, open source mobile analytics application. 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.

How to set up the project

  1. Fill Countly prefab with ServerUrl and AppKey. Also you can set up other countly parameters.

  1. Change notification icons if necessary. All icons are placed in folder /Plugins/Android/Notifications/res. You can find more information in official Android documentation.
  2. Register in Firebase and create google-services.xml from google-services.json. You can use online converter here. Put your file google-services.xml in /Plugins/Android/Notifications/res/values (replace if necessary).
  3. Put your applicationId in mainTemplate.gradle. Read more about mainTemplate here
  4. Set Write Permission to 'External (SDCard)'. Sometimes it is required for iBoxDb.

How to use this SDK

In order to start using countly you need to attach script CountlyEntryPoint to any gameobject on your scene and assign Countly and CountlyWrapper prefabs to proper fields. All prefabs are stored in Prefabs folder. CountlyWrapper is used only in Editor mode, it emulates and logs all events. Countly is used in production. It contains all settings. Just do not forget put ServerUrl and AppKey into Countly prefab :) Example scene: EntryPoint in folder Scenes.

The core class of an entire SDK is Countly.cs. You can use any handler from that class.

List of handlers:

  1. Consents
  2. CrushReports
  3. Device
  4. Events - use this handler to publish any custom events.
  5. Initialization
  6. OptionalParameters
  7. RemoteConfigs - use this handler to retrieve remote configs.
  8. StarRating
  9. UserDetails - use this handler to publish any user parameters including custom attributes.
  10. Views - use this handler to publish any custom events.

Examples:

//Record event
await Plugins.Countly.Impl.Countly.Instance.Events.RecordEventAsync("Test event");

//Record event and add segment 'useNumberInSameSession'
await Plugins.Countly.Impl.Countly.Instance.Events.RecordEventAsync("Test event", true);

//Report view event
await Plugins.Countly.Impl.Countly.Instance.Views.RecordOpenViewAsync("Menu");
await Plugins.Countly.Impl.Countly.Instance.Views.RecordCloseViewAsync("Menu");

//Init remote configs
await Plugins.Countly.Impl.Countly.Instance.RemoteConfigs.InitConfig(); //you should wait a bit after calling this method till configs is loaded.

//Get configs
var configs = Plugins.Countly.Impl.Countly.Instance.Configs;

iOs. Messages (Push notifications)

iOs has native support for remote notifications. In Unity we removed deprecated UnityEngine.Ios.NotificationServices and replaced it with Unity Mobile Notifications Package, documentation here. This prevent compilation errors during a build process in Xcode.

Also notification settings can be configured via file NotificationSettings in Assets/Editor/com.unity.mobile.notifications. **IMPORTANT!!** When Unity recompiles code a checkbox 'Enable Push notifications' get disabled. You need to enable it manually before making a build.

In Countly prefab switch Notification Mode to anything but none None.

ANDROID. Messages (Push notifications)

On android all notifications are called messages. Countly works with FCS to send messages. There are two types of messages:

  • Notification messages, sometimes thought of as "display messages." These are handled by the FCM SDK automatically.
  • Data messages, which are handled by the client app.

ANDROID. Push notification messages from countly

Countly sends ONLY data messages.

There are two ways to send data messages via countly:

Json received on device:

{
  "message": {
    "token": "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "data": {
      "c.i": "5cee37ba7fdb4c235667a1fe",
      "c.l": "http://google.com",
      "test": "data",
      "badge": "123456",
      "sound": "default",
      "title": "Welcome",
      "message": "HelloWorld"
    }
  }
}

Json received on device:

{
  "message": {
    "token": "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "data": {
      "c.i": "5cee3826cdbe68192b25260e",
      "c.l": "http://google.com",
      "c.s": "true",
      "test": "data",
      "badge": "123456",
      "sound": "default",
      "title": "Welcome",
      "message": "HelloWorld"
    }
  }
}

About

Need help? See Countly SDK for Unity documentation at Countly Resources, or ask us on our Countly Analytics Community Slack channel.

Security

Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to security@count.ly and not by creating a GitHub issue.

Other Github resources

This SDK needs one of the following Countly Editions to work:

For more information about Countly Enterprise Edition, see comparison of different Countly editions

There are also other Countly SDK repositories (both official and community supported) on Countly resources.

How can I help you with your efforts?

Glad you asked. We need ideas, feedback and constructive comments. All your suggestions will be taken care with utmost importance. We are on Twitter and Facebook if you would like to keep up with our fast progress!

Badges

If you like Countly, why not use one of our badges and give a link back to us, so others know about this wonderful platform?

Countly - Product Analytics

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/dark.svg" alt="Countly - Product Analytics" /></a>

Countly - Product Analytics

<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://count.ly/badges/light.svg" alt="Countly - Product Analytics" /></a>

Support

For Community support, visit http://community.count.ly.

About

Countly Product Analytics Unity SDK

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 80.2%
  • Java 10.7%
  • Objective-C 9.1%