app center;增加發送ping的秒
This commit is contained in:
1 parent
1bd1ffdb5a
commit
d754ff3b15
719 files changed
+34172
-2875
No files matched your search
@@ -0,0 +1,260 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using Microsoft.AppCenter.Unity.Internal;
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
using ServiceType = System.IntPtr;
|
||||
#else
|
||||
using ServiceType = System.Type;
|
||||
#endif
|
||||
|
||||
public class AppCenter
|
||||
{
|
||||
private static AppCenterTask<string> _secretTask = new AppCenterTask<string>();
|
||||
private static AppCenterTask<string> _logUrlTask = new AppCenterTask<string>();
|
||||
private static AppCenterTask<long> _storageSizeTask = new AppCenterTask<long>();
|
||||
|
||||
public static LogLevel LogLevel
|
||||
{
|
||||
get { return (LogLevel)AppCenterInternal.GetLogLevel(); }
|
||||
set { AppCenterInternal.SetLogLevel((int)value); }
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(bool enabled)
|
||||
{
|
||||
return AppCenterInternal.SetEnabledAsync(enabled);
|
||||
}
|
||||
|
||||
public static void StartFromLibrary(Type[] servicesArray)
|
||||
{
|
||||
AppCenterInternal.StartFromLibrary(AppCenterInternal.ServicesToNativeTypes(servicesArray));
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync()
|
||||
{
|
||||
return AppCenterInternal.IsEnabledAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the unique installation identifier for this application installation on this device.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The identifier is lost if clearing application data or uninstalling application.
|
||||
/// </remarks>
|
||||
public static AppCenterTask<Guid?> GetInstallIdAsync()
|
||||
{
|
||||
var stringTask = AppCenterInternal.GetInstallIdAsync();
|
||||
var guidTask = new AppCenterTask<Guid?>();
|
||||
stringTask.ContinueWith(t =>
|
||||
{
|
||||
var installId = !string.IsNullOrEmpty(t.Result) ? new Guid(t.Result) : (Guid?)null;
|
||||
guidTask.SetResult(installId);
|
||||
});
|
||||
return guidTask;
|
||||
}
|
||||
|
||||
public static string GetSdkVersion()
|
||||
{
|
||||
return AppCenterInternal.GetSdkVersion();
|
||||
}
|
||||
|
||||
public static AppCenterTask<string> GetLogUrlAsync()
|
||||
{
|
||||
if (_logUrlTask == null)
|
||||
{
|
||||
_logUrlTask = new AppCenterTask<string>();
|
||||
}
|
||||
return _logUrlTask;
|
||||
}
|
||||
|
||||
public static AppCenterTask<long> GetStorageSizeAsync()
|
||||
{
|
||||
if (_storageSizeTask == null)
|
||||
{
|
||||
_storageSizeTask = new AppCenterTask<long>();
|
||||
}
|
||||
return _storageSizeTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the base URL (scheme + authority + port only) used to communicate with the backend.
|
||||
/// </summary>
|
||||
/// <param name="logUrl">Base URL to use for server communication.</param>
|
||||
public static void SetLogUrl(string logUrl)
|
||||
{
|
||||
AppCenterInternal.SetLogUrl(logUrl);
|
||||
}
|
||||
|
||||
public static bool NetworkRequestsAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppCenterInternal.IsNetworkRequestsAllowed();
|
||||
}
|
||||
set
|
||||
{
|
||||
AppCenterInternal.SetNetworkRequestsAllowed(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CacheStorageSize(long storageSize)
|
||||
{
|
||||
if (_storageSizeTask != null)
|
||||
{
|
||||
_storageSizeTask.SetResult(storageSize);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CacheLogUrl(string logUrl)
|
||||
{
|
||||
if (_logUrlTask != null)
|
||||
{
|
||||
_logUrlTask.SetResult(logUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether SDK has already been configured or not.
|
||||
/// </summary>
|
||||
public static bool Configured
|
||||
{
|
||||
get { return AppCenterInternal.IsConfigured(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the custom properties.
|
||||
/// </summary>
|
||||
/// <param name="customProperties">Custom properties object.</param>
|
||||
public static void SetCustomProperties(Unity.CustomProperties customProperties)
|
||||
{
|
||||
var rawCustomProperties = customProperties.GetRawObject();
|
||||
AppCenterInternal.SetCustomProperties(rawCustomProperties);
|
||||
}
|
||||
|
||||
public static void SetWrapperSdk()
|
||||
{
|
||||
AppCenterInternal.SetWrapperSdk(WrapperSdk.WrapperSdkVersion, WrapperSdk.Name, WrapperSdk.WrapperRuntimeVersion, null, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
// Gets cached secret.
|
||||
/// </summary>
|
||||
public static AppCenterTask<string> GetSecretForPlatformAsync()
|
||||
{
|
||||
if (_secretTask == null)
|
||||
{
|
||||
_secretTask = new AppCenterTask<string>();
|
||||
}
|
||||
return _secretTask;
|
||||
}
|
||||
|
||||
// Gets the first instance of an app secret corresponding to the given platform name, or returns the string
|
||||
// as-is if no identifier can be found.
|
||||
public static string ParseAndSaveSecretForPlatform(string secrets)
|
||||
{
|
||||
var platformIdentifier = GetPlatformIdentifier();
|
||||
if (platformIdentifier == null)
|
||||
{
|
||||
// Return as is for unsupported platform.
|
||||
return secrets;
|
||||
}
|
||||
if (secrets == null)
|
||||
{
|
||||
// If "secrets" is null, return that and let the error be dealt
|
||||
// with downstream.
|
||||
return secrets;
|
||||
}
|
||||
|
||||
// If there are no equals signs, then there are no named identifiers
|
||||
if (!secrets.Contains("="))
|
||||
{
|
||||
return secrets;
|
||||
}
|
||||
|
||||
var platformIndicator = platformIdentifier + "=";
|
||||
var secretIdx = secrets.IndexOf(platformIndicator, StringComparison.Ordinal);
|
||||
if (secretIdx == -1)
|
||||
{
|
||||
// If the platform indicator can't be found, return the original
|
||||
// string and let the error be dealt with downstream.
|
||||
return secrets;
|
||||
}
|
||||
secretIdx += platformIndicator.Length;
|
||||
var platformSecret = string.Empty;
|
||||
|
||||
while (secretIdx < secrets.Length)
|
||||
{
|
||||
var nextChar = secrets[secretIdx++];
|
||||
if (nextChar == ';')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
platformSecret += nextChar;
|
||||
}
|
||||
if (_secretTask != null)
|
||||
{
|
||||
_secretTask.SetResult(platformSecret);
|
||||
}
|
||||
return platformSecret;
|
||||
}
|
||||
|
||||
public static void SetUserId(string userId)
|
||||
{
|
||||
AppCenterInternal.SetUserId(userId);
|
||||
}
|
||||
|
||||
#if ENABLE_IL2CPP
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
#endif
|
||||
public delegate void SetMaxStorageSizeCompletionHandler(bool result);
|
||||
|
||||
private static string GetPlatformIdentifier()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
return "ios";
|
||||
#elif UNITY_ANDROID
|
||||
return "android";
|
||||
#elif UNITY_WSA_10_0
|
||||
return "uwp";
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Type Analytics
|
||||
{
|
||||
get { return AppCenterAssembly.GetType("Microsoft.AppCenter.Unity.Analytics.Analytics"); }
|
||||
}
|
||||
|
||||
public static Type Crashes
|
||||
{
|
||||
get { return AppCenterAssembly.GetType("Microsoft.AppCenter.Unity.Crashes.Crashes"); }
|
||||
}
|
||||
|
||||
public static Type Distribute
|
||||
{
|
||||
get { return AppCenterAssembly.GetType("Microsoft.AppCenter.Unity.Distribute.Distribute"); }
|
||||
}
|
||||
|
||||
private static Assembly AppCenterAssembly
|
||||
{
|
||||
get
|
||||
{
|
||||
#if !UNITY_EDITOR && UNITY_WSA_10_0
|
||||
return typeof(AppCenterSettings).GetTypeInfo().Assembly;
|
||||
#else
|
||||
return Assembly.GetExecutingAssembly();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e56c11cd54154473f90634ed7e9ca5ff
|
||||
timeCreated: 1497042836
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
/// <summary>
|
||||
/// AppCenterTask provides a way of performing long-running
|
||||
/// tasks on any thread and invoking callbacks upon completion.
|
||||
/// </summary>
|
||||
public partial class AppCenterTask
|
||||
{
|
||||
private readonly List<Action<AppCenterTask>> _continuationActions = new List<Action<AppCenterTask>>();
|
||||
protected readonly object _lockObject = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="T:Microsoft.AppCenter.Unity.AppCenterTask"/> is complete.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if it is complete; otherwise, <c>false</c>.</value>
|
||||
public bool IsComplete { get; private set; }
|
||||
|
||||
public AppCenterTask()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a callback that will be invoked once the task is complete. If
|
||||
/// the task is already complete, it is invoked immediately after being set.
|
||||
/// </summary>
|
||||
/// <param name="continuationAction">Callback to be invoked after task completion.</param>
|
||||
public void ContinueWith(Action<AppCenterTask> continuationAction)
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
_continuationActions.Add(continuationAction);
|
||||
InvokeContinuationActions();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes callbacks and sets completion flag.
|
||||
/// </summary>
|
||||
protected virtual void CompletionAction()
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
IsComplete = true;
|
||||
InvokeContinuationActions();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if the task has completed.
|
||||
/// </summary>
|
||||
protected void ThrowIfCompleted()
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
if (IsComplete)
|
||||
{
|
||||
throw new InvalidOperationException("The task has already completed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an already completed task.
|
||||
/// </summary>
|
||||
/// <returns>The completed task.</returns>
|
||||
internal static AppCenterTask FromCompleted()
|
||||
{
|
||||
var task = new AppCenterTask();
|
||||
task.CompletionAction();
|
||||
return task;
|
||||
}
|
||||
|
||||
private void InvokeContinuationActions()
|
||||
{
|
||||
// Save the actions and then invoke them; could have a deadlock
|
||||
// if one of the actions calls ContinueWith on another thread for
|
||||
// the same task object.
|
||||
var continuationActionsSnapshot = new List<Action<AppCenterTask>>();
|
||||
lock (_lockObject)
|
||||
{
|
||||
if (!IsComplete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var action in _continuationActions)
|
||||
{
|
||||
if (action != null)
|
||||
{
|
||||
continuationActionsSnapshot.Add(action);
|
||||
}
|
||||
}
|
||||
_continuationActions.Clear();
|
||||
}
|
||||
foreach (var action in continuationActionsSnapshot)
|
||||
{
|
||||
action(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b355d0a7f1d647e589c9af62ffdcb77
|
||||
timeCreated: 1501260535
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if NET_4_6 || CSHARP_7_3_OR_NEWER || (UNITY_2018_3_OR_NEWER && NET_STANDARD_2_0)
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
public partial class AppCenterTask
|
||||
{
|
||||
public TaskAwaiter GetAwaiter()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
ContinueWith(task => taskCompletionSource.SetResult(true));
|
||||
return ((Task)taskCompletionSource.Task).GetAwaiter();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class AppCenterTask<TResult>
|
||||
{
|
||||
public new TaskAwaiter<TResult> GetAwaiter()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<TResult>();
|
||||
ContinueWith(task =>
|
||||
{
|
||||
if (task.Exception == null)
|
||||
{
|
||||
taskCompletionSource.SetResult(task.Result);
|
||||
}
|
||||
else{
|
||||
taskCompletionSource.SetException(task.Exception);
|
||||
}
|
||||
});
|
||||
return taskCompletionSource.Task.GetAwaiter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce92b141edc605e43a3a3183c25b34fb
|
||||
timeCreated: 1502286255
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
/// <summary>
|
||||
/// AppCenterTask<TResult> extends the functionality of AppCenterTask
|
||||
/// to support return values.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The return type of the task.</typeparam>
|
||||
/// <seealso cref="AppCenterTask"/>
|
||||
public partial class AppCenterTask<TResult> : AppCenterTask
|
||||
{
|
||||
public AppCenterTask() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a callback that will be invoked once the task is complete. If
|
||||
/// the task is already complete, it is invoked immediately after being set.
|
||||
/// </summary>
|
||||
/// <param name="continuationAction">Callback to be invoked after task completion.</param>
|
||||
public void ContinueWith(Action<AppCenterTask<TResult>> continuationAction)
|
||||
{
|
||||
base.ContinueWith(task => continuationAction(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an already completed task with a given result.
|
||||
/// </summary>
|
||||
/// <returns>The completed task.</returns>
|
||||
internal static AppCenterTask<TResult> FromCompleted(TResult result)
|
||||
{
|
||||
var task = new AppCenterTask<TResult>();
|
||||
task.SetResult(result);
|
||||
return task;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd2e77c86f30b4e44a532389560faf3e
|
||||
timeCreated: 1501260535
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
public partial class AppCenterTask : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting
|
||||
{
|
||||
get { return !IsComplete; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dea2e27c94e4e4b4c81b4066dbf1310f
|
||||
timeCreated: 1502286090
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using Microsoft.AppCenter.Unity.Internal;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
#if UNITY_IOS
|
||||
using RawType = System.IntPtr;
|
||||
#elif UNITY_ANDROID
|
||||
using RawType = UnityEngine.AndroidJavaObject;
|
||||
#else
|
||||
using RawType = System.Object;
|
||||
#endif
|
||||
|
||||
public class CustomProperties
|
||||
{
|
||||
private readonly RawType _rawObject;
|
||||
|
||||
internal RawType GetRawObject()
|
||||
{
|
||||
return _rawObject;
|
||||
}
|
||||
|
||||
public CustomProperties()
|
||||
{
|
||||
_rawObject = CustomPropertiesInternal.Create();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, string val)
|
||||
{
|
||||
CustomPropertiesInternal.SetString(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, DateTime val)
|
||||
{
|
||||
CustomPropertiesInternal.SetDate(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, int val)
|
||||
{
|
||||
CustomPropertiesInternal.SetNumber(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, long val)
|
||||
{
|
||||
CustomPropertiesInternal.SetNumber(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, float val)
|
||||
{
|
||||
CustomPropertiesInternal.SetNumber(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, double val)
|
||||
{
|
||||
CustomPropertiesInternal.SetNumber(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified property value with the specified key.
|
||||
/// If the properties previously contained a property for the key, the old value is replaced.
|
||||
/// </summary>
|
||||
/// <param name="key">Key with which the specified value is to be set.</param>
|
||||
/// <param name="val">Value to be set with the specified key.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Set(string key, bool val)
|
||||
{
|
||||
CustomPropertiesInternal.SetBool(_rawObject, key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the property for the specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">Key whose mapping is to be cleared.</param>
|
||||
/// <returns>This instance.</returns>
|
||||
public CustomProperties Clear(string key)
|
||||
{
|
||||
CustomPropertiesInternal.Clear(_rawObject, key);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5bc08888e1954d1586b49469659b087
|
||||
timeCreated: 1498516072
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the SDK.
|
||||
/// </summary>
|
||||
public string SdkName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Version of the SDK.
|
||||
/// </summary>
|
||||
public string SdkVersion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Device model (example: iPad2,3).
|
||||
/// </summary>
|
||||
public string Model { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Device manufacturer (example: HTC).
|
||||
/// </summary>
|
||||
public string OemName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// OS name (example: iOS).
|
||||
/// </summary>
|
||||
public string OsName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// OS version (example: 9.3.0).
|
||||
/// </summary>
|
||||
public string OsVersion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// OS build code (example: LMY47X).
|
||||
/// </summary>
|
||||
public string OsBuild { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// API level when applicable like in Android (example: 15).
|
||||
/// </summary>
|
||||
public int OsApiLevel { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Language code (example: en_US).
|
||||
/// </summary>
|
||||
public string Locale { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The offset in minutes from UTC for the device time zone, including daylight savings time.
|
||||
/// </summary>
|
||||
public int TimeZoneOffset { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Screen size of the device in pixels (example: 640x480).
|
||||
/// </summary>
|
||||
public string ScreenSize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Application version name.
|
||||
/// </summary>
|
||||
public string AppVersion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Carrier name (for mobile devices).
|
||||
/// </summary>
|
||||
public string CarrierName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Carrier country code (for mobile devices).
|
||||
/// </summary>
|
||||
public string CarrierCountry { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app's build number, e.g. 42.
|
||||
/// </summary>
|
||||
public string AppBuild { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The bundle identifier, package identifier, or namespace, depending on what the individual platforms use, .e.g com.microsoft.example.
|
||||
/// </summary>
|
||||
public string AppNamespace { get; private set; }
|
||||
|
||||
public Device(string sdkName, string sdkVersion, string model, string oemName, string osName, string osVersion, string osBuild,
|
||||
int osApiLevel, string locale, int timeZoneOffset, string screenSize, string appVersion, string carrierName,
|
||||
string carrierCountry, string appBuild, string appNamespace)
|
||||
{
|
||||
SdkName = sdkName;
|
||||
SdkVersion = sdkVersion;
|
||||
Model = model;
|
||||
OemName = oemName;
|
||||
OsName = osName;
|
||||
OsVersion = osVersion;
|
||||
OsBuild = osBuild;
|
||||
OsApiLevel = osApiLevel;
|
||||
Locale = locale;
|
||||
TimeZoneOffset = timeZoneOffset;
|
||||
ScreenSize = screenSize;
|
||||
AppVersion = appVersion;
|
||||
CarrierName = carrierName;
|
||||
CarrierCountry = carrierCountry;
|
||||
AppBuild = appBuild;
|
||||
AppNamespace = appNamespace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b59dd73cf53a7d2499c8a01185dcc11b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
/// <summary>
|
||||
/// Log level threshold for logs emitted by the SDK.
|
||||
/// </summary>
|
||||
public enum LogLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK emits all possible level of logs.
|
||||
/// </summary>
|
||||
Verbose = 2,
|
||||
|
||||
/// <summary>
|
||||
/// SDK emits debug, info, warn, error and assert logs.
|
||||
/// </summary>
|
||||
Debug = 3,
|
||||
|
||||
/// <summary>
|
||||
/// SDK emits info, warn, error, and assert logs.
|
||||
/// </summary>
|
||||
Info = 4,
|
||||
|
||||
/// <summary>
|
||||
/// SDK emits warn, error, and assert logs.
|
||||
/// </summary>
|
||||
Warn = 5,
|
||||
|
||||
/// <summary>
|
||||
/// SDK error and assert logs.
|
||||
/// </summary>
|
||||
Error = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Only assert logs are emitted by SDK.
|
||||
/// </summary>
|
||||
Assert = 7,
|
||||
|
||||
/// <summary>
|
||||
/// No log is emitted by SDK.
|
||||
/// </summary>
|
||||
#if UNITY_IOS
|
||||
None = 99
|
||||
#else
|
||||
None = 8
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81f2ae24f118f4c119ce594be70b0271
|
||||
timeCreated: 1497285830
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Startup mode.
|
||||
/// </summary>
|
||||
public enum StartupType
|
||||
{
|
||||
/// <summary>
|
||||
/// The app starts with SDK using an appSecret that is targeting AppCenter.
|
||||
/// If you send events in the app it will thus go to App Center portal.
|
||||
/// </summary>
|
||||
AppCenter = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Only Analytics is usable, other modules appear disabled.
|
||||
/// </summary>
|
||||
OneCollector = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Events go to OneCollector, crashes go to AppCenter.
|
||||
/// </summary>
|
||||
Both = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Sending an event does nothing and you have to use alternate transmission targets.
|
||||
/// Only the Analytics module appears enabled.
|
||||
/// </summary>
|
||||
NoSecret = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Don’t start the SDK: like NoSecret, except the SDK is not even started when launching the application.
|
||||
/// All modules will appear disabled.
|
||||
/// </summary>
|
||||
Skip = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ae70a3509fd43342bbbe6b6527ef068
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Internal.Utils
|
||||
{
|
||||
#if UNITY_WSA_10_0
|
||||
using WSAApplication = UnityEngine.WSA.Application;
|
||||
#endif
|
||||
|
||||
public class UnityCoroutineHelper : MonoBehaviour
|
||||
{
|
||||
private static UnityCoroutineHelper Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
var instance = FindObjectOfType<UnityCoroutineHelper>();
|
||||
if (instance == null)
|
||||
{
|
||||
var gameObject = new GameObject("App Center Helper")
|
||||
{
|
||||
hideFlags = HideFlags.HideAndDontSave
|
||||
};
|
||||
DontDestroyOnLoad(gameObject);
|
||||
instance = gameObject.AddComponent<UnityCoroutineHelper>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_WSA_10_0
|
||||
public static void StartCoroutine(Func<IEnumerator> coroutine)
|
||||
{
|
||||
if (WSAApplication.RunningOnAppThread())
|
||||
{
|
||||
Instance.StartCoroutine(coroutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
WSAApplication.InvokeOnAppThread(() =>
|
||||
{
|
||||
Instance.StartCoroutine(coroutine());
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
#else
|
||||
public static void StartCoroutine(Func<IEnumerator> coroutine)
|
||||
{
|
||||
Instance.StartCoroutine(coroutine());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de568185273ac461ebcb0c983415f3d8
|
||||
timeCreated: 1502882164
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity
|
||||
{
|
||||
public static class WrapperSdk
|
||||
{
|
||||
private static string _wrapperRuntimeVersion;
|
||||
private static bool _hasAttemptedToGetRuntimeVersion;
|
||||
|
||||
public const string Name = "appcenter.unity";
|
||||
public const string WrapperSdkVersion = "4.3.0";
|
||||
|
||||
internal static string WrapperRuntimeVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
// Use a flag instead of checking if _wrapperRuntimeVersion == null, because
|
||||
// GetWrapperRuntimeVersion() can return null
|
||||
return _hasAttemptedToGetRuntimeVersion ? _wrapperRuntimeVersion : (_wrapperRuntimeVersion = GetWrapperRuntimeVersion());
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetWrapperRuntimeVersion()
|
||||
{
|
||||
_hasAttemptedToGetRuntimeVersion = true;
|
||||
Type type = Type.GetType("Mono.Runtime");
|
||||
if (type != null)
|
||||
{
|
||||
MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName != null)
|
||||
{
|
||||
return (string)displayName.Invoke(null, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8d397a69ce0a4b8c84b42327b4002ef
|
||||
timeCreated: 1498672772
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user