Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Release AppMetrica Xamarin Plugin 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliaksei Nestsiarovich committed Jul 13, 2018
1 parent e50619b commit 157bbd4
Show file tree
Hide file tree
Showing 72 changed files with 7,363 additions and 4,255 deletions.
89 changes: 56 additions & 33 deletions LICENSE.md

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# AppMetrica Xamarin Plugin

## Documentation
Documentation available on [metrica official site][DOCUMENTATION].
Documentation available on [metrica official site] [DOCUMENTATION].

## Sample project
Sample projects (Xamarin Native and Xamarin Forms) to use is available at [samples/][GitHubSAMPLE].
Sample projects (Xamarin Native and Xamarin Forms) to use is available at [samples/] [GitHubSAMPLE].

## AppStore submit notice
Starting from version 1.6.0 Yandex AppMetrica became also a tracking instrument and
Expand All @@ -16,24 +16,31 @@ advertisement**.

## Changelog

### Version 2.0.0
* Updated AppMetrica SDK versions (iOS 3.1.2, Android 3.1.0).
* Changed the SDK to meet the requirements of the Apple App Store Review Team. Update the plugin to avoid any issues during the App Store moderation process.
* Changed API methods.
* Added a method for getting the configuration of the AppMetrica Push Xamarin plugin.
* Fixed an [issue](https://github.com/yandexmobile/metrica-plugin-xamarin/issues/5) when using custom Application class

### Version 1.1.0
* Updated AppMetrica libs: iOS 2.6.5 and Android 2.6.0.
* Updated script for iOS AppMetrica lib updating.

### Version 1.0.0
* Updated AppMetrica libs: iOS 2.5.1 and Android 2.4.2.
* Released [NuGet package][NuGetPackage].
* Released [NuGet package] [NuGetPackage].

### Version 0.1.0
* Implemented bindings for AppMetrica iOS (v2.1.1) and AppMetrica Android (v2.23).
* Implemented PCL wrapper for bindings.
* Provided samples for Xamarin Native and Xamarin Forms (iOS and Android).

## License
License agreement on use of Yandex AppMetrica is available at [EULA site][LICENSE]
License agreement on use of Yandex AppMetrica is available at [EULA site] [LICENSE]


[LICENSE]: https://yandex.com/legal/metrica_termsofuse/ "Yandex AppMetrica agreement"
[LICENSE]: https://yandex.com/legal/appmetrica_sdk_agreement/ "Yandex AppMetrica agreement"
[DOCUMENTATION]: https://tech.yandex.ru/metrica-mobile-sdk/doc/mobile-sdk-dg/concepts/xamarin-plugin-docpage/ "Yandex AppMetrica Xamarin Plugin documentation"
[GitHubSAMPLE]: https://github.com/yandexmobile/metrica-plugin-xamarin/tree/master/samples "Samples from reository"
[NuGetPackage]: https://www.nuget.org/packages/Yandex.Metrica.Xamarin/ "NuGet package"
12 changes: 10 additions & 2 deletions SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
using System.Reflection;
/*
* Version for Xamarin
* © 2015-2017 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyDescription("")]
Expand All @@ -9,4 +17,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyVersion("2.0.0")]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Version for Xamarin
* © 2015-2017 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

using System;
using Android.App;
using Android.Content;
using Android.OS;

namespace YandexMetricaAndroid
{
/// <summary>
/// This class does nothing, but it is needed to run the application with a custom Application class.
/// </summary>
[Service(Process = ":Metrica")]
public class MetricaMonoRuntimeLoaderService : Service
{
public override IBinder OnBind(Intent intent)
{
return null;
}
}
}
10 changes: 9 additions & 1 deletion YandexMetrica.Xamarin.AndroidBinding/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
using System.Reflection;
/*
* Version for Xamarin
* © 2015-2017 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

using System.Reflection;
using System.Runtime.CompilerServices;
using Android.App;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
<AssemblyName>YandexMetrica.Xamarin.Android</AssemblyName>
<ReleaseVersion>1.1.0</ReleaseVersion>
<ReleaseVersion>2.0.0</ReleaseVersion>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -45,6 +46,7 @@
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="MetricaMonoRuntimeLoaderService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Additions\AboutAdditions.txt" />
Expand All @@ -63,6 +65,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<LibraryProjectZip Include="Jars\mobmetricalib-2.60.aar" />
<LibraryProjectZip Include="Jars\mobmetricalib-3.1.0.aar" />
</ItemGroup>
</Project>
165 changes: 72 additions & 93 deletions YandexMetrica.Xamarin.AndroidBinding/YandexMetricaImplementation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
using System;
/*
* Version for Xamarin
* © 2015-2017 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

using System;
using System.Collections.Generic;
using Android.Content;
using Android.Locations;
Expand All @@ -7,59 +15,15 @@

namespace YandexMetricaAndroid
{
public class YandexMetricaImplementation : IYandexMetrica
public class YandexMetricaImplementation : BaseYandexMetrica
{
public static void Activate(Context context, string apiKey, Application app = null)
public static void Activate(Context context, YandexMetricaConfig config, Application app = null)
{
YandexMetrica.RegisterImplementation(new YandexMetricaImplementation());

Com.Yandex.Metrica.YandexMetrica.Activate(context, apiKey);
Com.Yandex.Metrica.YandexMetrica.Activate(context, config.ToAndroidMetricaConfig());
EnableActivityAutoTracking(app);

// Native crashes are currently not supported
Com.Yandex.Metrica.YandexMetrica.SetReportNativeCrashesEnabled(false);
}

public static void Activate(Context context, YandexMetricaConfig config, Application app = null)
{
YandexMetrica.RegisterImplementation(new YandexMetricaImplementation());

var builder = Com.Yandex.Metrica.YandexMetricaConfig.NewConfigBuilder(config.ApiKey);

if (config.Location != null) {
builder.SetLocation(config.Location.ToLocation());
}
if (config.AppVersion != null) {
builder.SetAppVersion(config.AppVersion);
}
if (config.TrackLocationEnabled.HasValue) {
builder.SetTrackLocationEnabled(config.TrackLocationEnabled.Value);
}
if (config.SessionTimeout.HasValue) {
builder.SetSessionTimeout(config.SessionTimeout.Value);
}
if (config.ReportCrashesEnabled.HasValue) {
builder.SetReportCrashesEnabled(config.ReportCrashesEnabled.Value);
}
if (config.LoggingEnabled.HasValue && config.LoggingEnabled.Value) {
builder.SetLogEnabled();
}
if (config.CollectInstalledApps.HasValue) {
builder.SetCollectInstalledApps(config.CollectInstalledApps.Value);
}
if (config.PreloadInfo != null) {
var preloadInfoBuilder = Com.Yandex.Metrica.PreloadInfo.NewBuilder(config.PreloadInfo.TrackingId);
foreach (var kvp in config.PreloadInfo.AdditionalInfo) {
preloadInfoBuilder.SetAdditionalParams(kvp.Key, kvp.Value);
}
builder.SetPreloadInfo(preloadInfoBuilder.Build());
}

// Native crashes are currently not supported
builder.SetReportNativeCrashesEnabled(false);

Com.Yandex.Metrica.YandexMetrica.Activate(context, builder.Build());
EnableActivityAutoTracking(app);
UpdateConfiguration(config);
}

private static void EnableActivityAutoTracking(Application app)
Expand All @@ -69,22 +33,22 @@ private static void EnableActivityAutoTracking(Application app)
}
}

public static void OnPauseActivity(Activity activity)
public static void PauseSession(Activity activity)
{
Com.Yandex.Metrica.YandexMetrica.OnPauseActivity(activity);
Com.Yandex.Metrica.YandexMetrica.PauseSession(activity);
}

public static void OnResumeActivity(Activity activity)
public static void ResumeSession(Activity activity)
{
Com.Yandex.Metrica.YandexMetrica.OnResumeActivity(activity);
Com.Yandex.Metrica.YandexMetrica.ResumeSession(activity);
}

public void ReportEvent(string message)
public override void ReportEvent(string message)
{
Com.Yandex.Metrica.YandexMetrica.ReportEvent(message);
}

public void ReportEvent(string message, IDictionary<string, string> parameters)
public override void ReportEvent(string message, IDictionary<string, string> parameters)
{
var jObjDict = new Dictionary<string, Java.Lang.Object>();
foreach (var kvp in parameters) {
Expand All @@ -93,66 +57,81 @@ public void ReportEvent(string message, IDictionary<string, string> parameters)
Com.Yandex.Metrica.YandexMetrica.ReportEvent(message, jObjDict);
}

public void ReportError(string message, Exception exception)
public override void ReportError(string message, Exception exception)
{
var throwable = Java.Lang.Throwable.FromException(exception);
Com.Yandex.Metrica.YandexMetrica.ReportError(message, throwable);
}

public void SetTrackLocationEnabled(bool enabled)
public override void SetLocationTracking(bool enabled)
{
Com.Yandex.Metrica.YandexMetrica.SetTrackLocationEnabled(enabled);
Com.Yandex.Metrica.YandexMetrica.SetLocationTracking(enabled);
}

public void SetLocation(Coordinates coordinates)
public override void SetLocation(Coordinates coordinates)
{
Com.Yandex.Metrica.YandexMetrica.SetLocation(coordinates.ToLocation());
}

public void SetSessionTimeout(uint sessionTimeoutSeconds)
{
Com.Yandex.Metrica.YandexMetrica.SetSessionTimeout((int)sessionTimeoutSeconds);
}
public override string LibraryVersion { get { return Com.Yandex.Metrica.YandexMetrica.LibraryVersion; } }

public void SetReportCrashesEnabled(bool enabled)
{
Com.Yandex.Metrica.YandexMetrica.SetReportCrashesEnabled(enabled);
}
public override int LibraryApiLevel { get { return Com.Yandex.Metrica.YandexMetrica.LibraryApiLevel; } }
}

public void SetCustomAppVersion(string appVersion)
public static class YandexMetricaExtensionsAndroid
{
public static Com.Yandex.Metrica.YandexMetricaConfig ToAndroidMetricaConfig(this YandexMetricaConfig self)
{
Com.Yandex.Metrica.YandexMetrica.SetCustomAppVersion(appVersion);
}
var builder = Com.Yandex.Metrica.YandexMetricaConfig.NewConfigBuilder(self.ApiKey);

public void SetLoggingEnabled()
{
Com.Yandex.Metrica.YandexMetrica.SetLogEnabled();
}
if (self.Location != null)
{
builder.WithLocation(self.Location.ToLocation());
}
if (self.AppVersion != null)
{
builder.WithAppVersion(self.AppVersion);
}
if (self.LocationTracking.HasValue)
{
builder.WithLocationTracking(self.LocationTracking.Value);
}
if (self.SessionTimeout.HasValue)
{
builder.WithSessionTimeout(self.SessionTimeout.Value);
}
if (self.CrashReporting.HasValue)
{
builder.WithCrashReporting(self.CrashReporting.Value);
}
if (self.Logs.HasValue && self.Logs.Value)
{
builder.WithLogs();
}
if (self.InstalledAppCollecting.HasValue)
{
builder.WithInstalledAppCollecting(self.InstalledAppCollecting.Value);
}
if (self.PreloadInfo != null)
{
var preloadInfoBuilder = Com.Yandex.Metrica.PreloadInfo.NewBuilder(self.PreloadInfo.TrackingId);
foreach (var kvp in self.PreloadInfo.AdditionalInfo)
{
preloadInfoBuilder.SetAdditionalParams(kvp.Key, kvp.Value);
}
builder.WithPreloadInfo(preloadInfoBuilder.Build());
}

public void SetEnvironmentValue(string key, string value)
{
Com.Yandex.Metrica.YandexMetrica.SetEnvironmentValue(key, value);
}
// Native crashes are currently not supported
builder.WithNativeCrashReporting(false);

public bool CollectInstalledApps {
get {
return Com.Yandex.Metrica.YandexMetrica.CollectInstalledApps;
}
set {
Com.Yandex.Metrica.YandexMetrica.CollectInstalledApps = value;
}
return builder.Build();
}

public string LibraryVersion { get { return Com.Yandex.Metrica.YandexMetrica.LibraryVersion; } }

public int LibraryApiLevel { get { return Com.Yandex.Metrica.YandexMetrica.LibraryApiLevel; } }
}

public static class Extensions
{
public static Location ToLocation(this Coordinates self)
{
return self == null ? null : new Location("") {
return self == null ? null : new Location("")
{
Latitude = self.Latitude,
Longitude = self.Longitude
};
Expand Down
Loading

0 comments on commit 157bbd4

Please sign in to comment.