Windows 8 - Basic implementation

R1 Connect Library for WP

Overview

Downloading R1ConnectLibrary.dll allows you to begin the integration process of adding R1 Connect services to your app. It supports all mobile and tablet devices running Windows Phone 8. The file itself contains the dynamic link library (DLL) of the R1 Connect SDK for WP. The library supports the following architectures:

  • arm
  • x86

Setup

The following steps will explain how to integrate with R1 Connect to enable both push notifications and event tracking. You have the option to use the R1 Connect Demo as a sample app project to begin with or you can use your own app. Once you have downloaded the R1 Connect Library from this repo you can add it to the same directory as your project.

Required Libraries

R1 Connect SDK required protobuf-net.dll library. You can find it in folder with R1ConnectLibrary.dll

How to Add the R1 Connect files to Your Project

  1. Open up your WP project or solution in Visual Studio.
  2. Select PROJECT -> Add Reference...
  3. In opened "Reference Manager" window press "Browse"
  4. Select downloaded libraries R1ConnectLibrary.dll and protobuf-net.dll

Check Capabilities

Check your application Capabilities. For it

  1. Open [Your project]->Properties->WMAppManifest.xml in Solution Explorer.
  2. Select Capabilities tab
  3. Check ID_CAP_NETWORKING, ID_CAP_IDENTITY_DEVICE, ID_CAP_LOCATION
  4. Check ID_CAP_PUSH_NOTIFICATION if you want use R1 Connect Push

If it’s turned off, please turn on.

Using R1Connect SDK Namespace

You have two ways to execute SDK methods. You can write namespace directly with method, for example:

Radiumone.Connect.Emitter.Instance.EmitEvent("Your custom event name");

Or you can add to top of your current .cs file (where the method is invoked)

using Radiumone.Connect;

and then simple call SDK methods without namespace prefix:

Emitter.Instance.EmitEvent("Your custom event name");

In all examples below used first scheme.

Setting up your Application

You will need to initialize the R1 Connect Library in your App.xaml.cs. You can load R1Connect SDK configuration from xml file or configure it in source code.

Initialize from xml file

Create xml file and add it to your application project:

<?xml version="1.0" encoding="utf-8" ?>
<R1ConnectConfig>
  <ApplicationId>[YOUR APPLICATION ID]</ApplicationId>
  <ClientKey>[YOUR CLIENT KEY]</ClientKey>
  <InProduction>false</InProduction>
  <MPNSServiceName>[YOUR PUSH CHANNEL]</MPNSServiceName>
  <MPNSChannelName>[YOUR SERVICE NAME]</MPNSChannelName>
  <TileAllowedDomains>
    <Domain>[TILES DOMAIN]</Domain>
  </TileAllowedDomains>
</R1ConnectConfig>

Start R1 Connect in your application App.xaml.cs

private void Application_Launching(object sender, LaunchingEventArgs e)
{
    // Start R1Connect SDK
    var xmlConfig = Radiumone.Connect.Config.LoadFromFile("R1ConnectConfig.xml");

    Radiumone.Connect.SDK.Instance.Start(config);
}

Initialize in source code

Start R1 Connect in your application App.xaml.cs

private void Application_Launching(object sender, LaunchingEventArgs e)
{
    // Start R1Connect SDK
    var config = new Radiumone.Connect.Config();
    config.ApplicationId = "[YOUR APPLICATION ID]";
    config.ClientKey = "[YOUR CLIENT KEY]";
    config.MPNSChannelName = "[YOUR PUSH CHANNEL]";
    config.MPNSServiceName = "[YOUR SERVICE NAME]";
    config.TileAllowedDomains.Add(new Uri("[TILES DOMAIN]"));
#if DEBUG
    config.InProduction = false;
#else
    config.InProduction = true;
#endif

    Radiumone.Connect.SDK.Instance.Start(config);
}

Push is disabled by default. You can enable it in the Application_Launching method or later.

Radiumone.Connect.Push.Instance.Enabled = true;

Emitter & Push Parameters

The following is a list of configuration parameters for the R1 Connect SDK, most of these contain values that are sent to the tracking server to help identify your app on our platform and to provide analytics on sessions and location.

Configuration Parameters

ApplicationUserId

Optional current user identifier.

Radiumone.Connect.SDK.Instance.ApplicationUserId = "12345";

LastCoordinate

The current user location coordinates. Use it only if your application already uses location services.

Radiumone.Connect.SDK.Instance.LastCoordinate = …;

LocationService

If your application did not use location information before this SDK installation, you can use LocationService in this SDK to enable or disable it:

Radiumone.Connect.SDK.Instance.LocationService.Enabled = true;

When enabled, such as in the example above, location information will be sent automatically. However, locationService doesn’t fetch the location constantly. For instance, when the location is received the SDK will turn off the location service and wait 10 minutes (by default) before attempting to retrieve it again. You can change this value:

Radiumone.Connect.SDK.Instance.LocationService.AutoupdateTimeout = 1200; // 20 minutes

AppVersion

The application version associated with this emitter. By default, this property is populated with the App Version string from the WMAppManifest.xml. If you wish to override this property, you must do so before making any tracking calls.

Radiumone.Connect.Emitter.Instance.AppVersion = "1.0.2";

SessionStart

If true, indicates the start of a new session. Note that when a emitter is first instantiated, this is initialized to true. To prevent this default behavior, set this to false when the tracker is first obtained.

By itself, setting this does not send any data. If this is true, when the next emitter call is made, a parameter will be added to the resulting emitter information indicating that it is the start of a session, and this flag will be cleared.

Radiumone.Connect.Emitter.Instance.SessionStart = true;
// Your code here
Radiumone.Connect.Emitter.Instance.SessionStart = false;

SessionTimeout

If non-negative, indicates how long, in seconds, the application must transition to the inactive or background state for before the tracker will automatically indicate the start of a new session when the app becomes active again by setting sessionStart to true. For example, if this is set to 30 seconds, and the user receives a phone call that lasts for 45 seconds while using the app, upon returning to the app, the sessionStart parameter will be set to true. If the phone call instead lasted 10 seconds, sessionStart will not be modified.

To disable automatic session tracking, set this to a negative value. To indicate the start of a session anytime the app becomes inactive or backgrounded, set this to zero.

By default, this is 30 seconds.

Radiumone.Connect.Emitter.Instance.SessionTimeout = 15;
 
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk