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

Commit

Permalink
Merge pull request #1 from yandexmobile/release-0.20
Browse files Browse the repository at this point in the history
Release 1.00
  • Loading branch information
bamx23 authored Jul 11, 2016
2 parents 8513af1 + 648d853 commit 68a41eb
Show file tree
Hide file tree
Showing 72 changed files with 773 additions and 2,559 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@ Documentation available on [metrica official site] [DOCUMENTATION].
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
uses Apple idfa to attribute installs. Because of that during submitting your
application to the AppStore you will be prompted with three checkboxes to state
Starting from version 1.6.0 Yandex AppMetrica became also a tracking instrument and
uses Apple idfa to attribute installs. Because of that during submitting your
application to the AppStore you will be prompted with three checkboxes to state
your intentions for idfa usage.
As YandexMetrica uses idfa for attributing app installations you need to select **Attribute this app installation to a previously served
As Yandex AppMetrica uses idfa for attributing app installations you need to select **Attribute this app installation to a previously served
advertisement**.

## Changelog

### Version 1.0.0
* Updated AppMetrica libs: iOS 2.5.1 and Android 2.4.2.
* 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 for Apps SDK 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"
[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"
2 changes: 1 addition & 1 deletion SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyVersion("1.0.0")]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
<AssemblyName>YandexMetrica.Xamarin.Android</AssemblyName>
<ReleaseVersion>1.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -55,13 +56,13 @@
<TransformFile Include="Transforms\Metadata.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
<ItemGroup>
<LibraryProjectZip Include="Jars\mobmetricalib-2.23.aar" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YandexMetrica.Xamarin.PCL\YandexMetrica.Xamarin.PCL.csproj">
<Project>{2220CE11-BFFD-4A34-82AC-5A7469A39828}</Project>
<Name>YandexMetrica.Xamarin.PCL</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<LibraryProjectZip Include="Jars\mobmetricalib-2.42.aar" />
</ItemGroup>
</Project>
74 changes: 64 additions & 10 deletions YandexMetrica.Xamarin.AndroidBinding/YandexMetricaImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,61 @@ public static void Activate(Context context, string apiKey, Application app = nu
YandexMetrica.RegisterImplementation(new YandexMetricaImplementation());

Com.Yandex.Metrica.YandexMetrica.Activate(context, apiKey);
if (app != null) {
Com.Yandex.Metrica.YandexMetrica.EnableActivityAutoTracking(app);
}
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);
}

private static void EnableActivityAutoTracking(Application app)
{
if (app != null) {
Com.Yandex.Metrica.YandexMetrica.EnableActivityAutoTracking(app);
}
}

public static void OnPauseActivity(Activity activity)
{
Com.Yandex.Metrica.YandexMetrica.OnPauseActivity(activity);
Expand Down Expand Up @@ -57,13 +104,9 @@ public void SetTrackLocationEnabled(bool enabled)
Com.Yandex.Metrica.YandexMetrica.SetTrackLocationEnabled(enabled);
}

public void SetLocation(float latitude, float longitude)
{
var location = new Location("") {
Latitude = latitude,
Longitude = longitude
};
Com.Yandex.Metrica.YandexMetrica.SetLocation(location);
public void SetLocation(Coordinates coordinates)
{
Com.Yandex.Metrica.YandexMetrica.SetLocation(coordinates.ToLocation());
}

public void SetSessionTimeout(uint sessionTimeoutSeconds)
Expand Down Expand Up @@ -104,5 +147,16 @@ public bool CollectInstalledApps {

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("") {
Latitude = self.Latitude,
Longitude = self.Longitude
};
}
}
}

10 changes: 10 additions & 0 deletions YandexMetrica.Xamarin.PCL/Coordinates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace YandexMetricaPCL
{
public sealed class Coordinates
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
}
5 changes: 2 additions & 3 deletions YandexMetrica.Xamarin.PCL/IYandexMetrica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public interface IYandexMetrica
/// <para>Android: public static void setLocation(final Location location)</para>
/// <para>iOS: +(void)setLocation:(CLLocation *)location</para>
/// </summary>
/// <param name="latitude">Location latitude.</param>
/// <param name="longitude">Location longitude.</param>
void SetLocation (float latitude, float longitude);
/// <param name="coordinates">Location coordinates(latitude and longitude).</param>
void SetLocation (Coordinates coordinates);

/// <summary>
/// <para>Sets the session timeout.</para>
Expand Down
4 changes: 4 additions & 0 deletions YandexMetrica.Xamarin.PCL/YandexMetrica.Xamarin.PCL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<AssemblyName>YandexMetrica.Xamarin.PCL</AssemblyName>
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>1.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -37,6 +38,9 @@
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="YandexMetricaConfig.cs" />
<Compile Include="YandexMetricaPreloadInfo.cs" />
<Compile Include="Coordinates.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
</Project>
23 changes: 23 additions & 0 deletions YandexMetrica.Xamarin.PCL/YandexMetricaConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace YandexMetricaPCL
{
public sealed class YandexMetricaConfig
{
public string ApiKey { get; private set; }
public string AppVersion { get; set; }
public Coordinates Location { get; set; }
public int? SessionTimeout { get; set; }
public bool? ReportCrashesEnabled { get; set; }
public bool? TrackLocationEnabled { get; set; }
public bool? LoggingEnabled { get; set; }
public bool? CollectInstalledApps { get; set; }

public YandexMetricaPreloadInfo PreloadInfo { get; set; }

public YandexMetricaConfig(string apiKey)
{
ApiKey = apiKey;
}
}
}
2 changes: 1 addition & 1 deletion YandexMetrica.Xamarin.PCL/YandexMetricaDummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void ReportError(string message, Exception exception) { }

public void SetTrackLocationEnabled(bool enabled) { }

public void SetLocation(float latitude, float longitude) { }
public void SetLocation(Coordinates coordinates) { }

public void SetSessionTimeout(uint sessionTimeoutSeconds) { }

Expand Down
17 changes: 17 additions & 0 deletions YandexMetrica.Xamarin.PCL/YandexMetricaPreloadInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;

namespace YandexMetricaPCL
{
public sealed class YandexMetricaPreloadInfo
{
public string TrackingId { get; private set; }
public Dictionary<string, string> AdditionalInfo { get; private set; }

public YandexMetricaPreloadInfo(string trackingId)
{
TrackingId = trackingId;
AdditionalInfo = new Dictionary<string, string>();
}
}
}
74 changes: 74 additions & 0 deletions YandexMetrica.Xamarin.iOSBinding/ApiDefinitions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using CoreLocation;
using Foundation;
using ObjCRuntime;

namespace YandexMetricaIOS
{
Expand All @@ -21,6 +22,11 @@ interface YMMYandexMetrica
[Export ("activateWithApiKey:")]
void ActivateWithApiKey (string apiKey);

// +(void)activateWithConfiguration:(YMMYandexMetricaConfiguration *)configuration;
[Static]
[Export ("activateWithConfiguration:")]
void ActivateWithConfiguration (YMMYandexMetricaConfiguration configuration);

// +(void)reportEvent:(NSString *)message onFailure:(void (^)(NSError *))onFailure;
[Static]
[Export ("reportEvent:onFailure:")]
Expand Down Expand Up @@ -75,6 +81,18 @@ interface YMMYandexMetrica
[Static]
[Export ("libraryVersion")]
string LibraryVersion { get; }

// +(BOOL)enableTrackingWithURLScheme:(NSURL *)urlScheme __attribute__((availability(ios, introduced=9_0))) __attribute__((availability(ios_app_extension, unavailable)));
[Introduced(PlatformName.iOS,9,0)]
[Static]
[Export ("enableTrackingWithURLScheme:")]
bool EnableTrackingWithURLScheme (NSUrl urlScheme);

// +(BOOL)handleOpenURL:(NSURL *)url __attribute__((availability(ios, introduced=9_0))) __attribute__((availability(ios_app_extension, unavailable)));
[Introduced(PlatformName.iOS,9,0)]
[Static]
[Export ("handleOpenURL:")]
bool HandleOpenURL (NSUrl url);
}

// @interface YMMYandexMetricaDeprecatedOrUnavailable (YMMYandexMetrica)
Expand All @@ -83,4 +101,60 @@ interface YMMYandexMetrica
interface YMMYandexMetrica_YMMYandexMetricaDeprecatedOrUnavailable
{
}

// @interface YMMYandexMetricaConfiguration : NSObject
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface YMMYandexMetricaConfiguration
{
// -(instancetype)initWithApiKey:(NSString *)apiKey;
[Export ("initWithApiKey:")]
IntPtr Constructor (string apiKey);

// @property (readonly, copy, nonatomic) NSString * apiKey;
[Export ("apiKey")]
string ApiKey { get; }

// @property (assign, nonatomic) BOOL trackLocationEnabled;
[Export ("trackLocationEnabled")]
bool TrackLocationEnabled { get; set; }

// @property (nonatomic, strong) CLLocation * location;
[Export ("location", ArgumentSemantic.Strong)]
CLLocation Location { get; set; }

// @property (assign, nonatomic) NSUInteger sessionTimeout;
[Export ("sessionTimeout")]
nuint SessionTimeout { get; set; }

// @property (assign, nonatomic) BOOL reportCrashesEnabled;
[Export ("reportCrashesEnabled")]
bool ReportCrashesEnabled { get; set; }

// @property (copy, nonatomic) NSString * customAppVersion;
[Export ("customAppVersion")]
string CustomAppVersion { get; set; }

// @property (assign, nonatomic) BOOL loggingEnabled;
[Export ("loggingEnabled")]
bool LoggingEnabled { get; set; }

// @property (copy, nonatomic) YMMYandexMetricaPreloadInfo * preloadInfo;
[Export ("preloadInfo", ArgumentSemantic.Copy)]
YMMYandexMetricaPreloadInfo PreloadInfo { get; set; }
}

// @interface YMMYandexMetricaPreloadInfo : NSObject <NSCopying>
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface YMMYandexMetricaPreloadInfo : INSCopying
{
// -(instancetype _Nonnull)initWithTrackingIdentifier:(NSString * _Nonnull)trackingID;
[Export ("initWithTrackingIdentifier:")]
IntPtr Constructor (string trackingID);

// -(void)setAdditionalInfo:(NSString * _Nonnull)info forKey:(NSString * _Nonnull)key;
[Export ("setAdditionalInfo:forKey:")]
void SetAdditionalInfo (string info, string key);
}
}
21 changes: 21 additions & 0 deletions YandexMetrica.Xamarin.iOSBinding/Headers/YMMVersion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* YMMVersion.h
*
* This file is a part of the AppMetrica
*
* Version for iOS © 2015 YANDEX
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/
*/

#ifndef __YMM_VERSION_H__
#define __YMM_VERSION_H__

#define YMM_VERSION_MAJOR 2
#define YMM_VERSION_MINOR 5
#define YMM_VERSION_PATCH 1

#define YMM_BUILD_NUMBER 5889

#endif // __YMM_VERSION_H__
Loading

0 comments on commit 68a41eb

Please sign in to comment.