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,96 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
class AnalyticsInternal
|
||||
{
|
||||
private static AndroidJavaClass _analytics = new AndroidJavaClass("com.microsoft.appcenter.analytics.Analytics");
|
||||
|
||||
public static void PrepareEventHandlers()
|
||||
{
|
||||
AppCenterBehavior.InitializedAppCenterAndServices += PostInitialize;
|
||||
}
|
||||
|
||||
private static void PostInitialize()
|
||||
{
|
||||
var instance = _analytics.CallStatic<AndroidJavaObject>("getInstance");
|
||||
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
instance.Call("onActivityResumed", activity);
|
||||
}
|
||||
|
||||
public static void AddNativeType(List<IntPtr> nativeTypes)
|
||||
{
|
||||
nativeTypes.Add(AndroidJNI.FindClass("com/microsoft/appcenter/analytics/Analytics"));
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName);
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName, int flags)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, null, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
_analytics.CallStatic("trackEvent", eventName, androidProperties);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, properties.GetRawObject());
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties, int flags)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
_analytics.CallStatic("trackEvent", eventName, androidProperties, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties, int flags)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, properties.GetRawObject(), flags);
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(bool isEnabled)
|
||||
{
|
||||
var future = _analytics.CallStatic<AndroidJavaObject>("setEnabled", isEnabled);
|
||||
return new AppCenterTask(future);
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync()
|
||||
{
|
||||
var future = _analytics.CallStatic<AndroidJavaObject>("isEnabled");
|
||||
return new AppCenterTask<bool>(future);
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetTransmissionTarget(string transmissionTargetToken, out bool success)
|
||||
{
|
||||
var target = _analytics.CallStatic<AndroidJavaObject>("getTransmissionTarget", transmissionTargetToken);
|
||||
success = target != null;
|
||||
return target;
|
||||
}
|
||||
|
||||
public static void Pause()
|
||||
{
|
||||
_analytics.CallStatic("pause");
|
||||
}
|
||||
|
||||
public static void Resume()
|
||||
{
|
||||
_analytics.CallStatic("resume");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a713100f59727486c9ad45c500332234
|
||||
timeCreated: 1497467718
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
class EventPropertiesInternal
|
||||
{
|
||||
public static AndroidJavaObject Create()
|
||||
{
|
||||
return new AndroidJavaObject("com.microsoft.appcenter.analytics.EventProperties");
|
||||
}
|
||||
|
||||
public static void SetString(AndroidJavaObject properties, string key, string val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetNumber(AndroidJavaObject properties, string key, long val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetNumber(AndroidJavaObject properties, string key, double val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetBool(AndroidJavaObject properties, string key, bool val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetDate(AndroidJavaObject properties, string key, DateTime val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, JavaDateHelper.DateTimeConvert(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 514cee750a1f56f4bab5c663b3a4f557
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics
|
||||
{
|
||||
public class PropertyConfiguratorInternal
|
||||
{
|
||||
public static void SetAppName(AndroidJavaObject propertyConfigurator, string appName)
|
||||
{
|
||||
propertyConfigurator.Call("setAppName", appName);
|
||||
}
|
||||
|
||||
public static void SetUserId(AndroidJavaObject propertyConfigurator, string userId)
|
||||
{
|
||||
propertyConfigurator.Call("setUserId", userId);
|
||||
}
|
||||
|
||||
public static void SetAppVersion(AndroidJavaObject propertyConfigurator, string appVersion)
|
||||
{
|
||||
propertyConfigurator.Call("setAppVersion", appVersion);
|
||||
}
|
||||
|
||||
public static void SetAppLocale(AndroidJavaObject propertyConfigurator, string appLocale)
|
||||
{
|
||||
propertyConfigurator.Call("setAppLocale", appLocale);
|
||||
}
|
||||
|
||||
public static void CollectDeviceId(AndroidJavaObject propertyConfigurator)
|
||||
{
|
||||
propertyConfigurator.Call("collectDeviceId");
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, string value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, DateTime value)
|
||||
{
|
||||
var javaDate = JavaDateHelper.DateTimeConvert(value);
|
||||
propertyConfigurator.Call("setEventProperty", key, javaDate);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, long value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, double value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, bool value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void RemoveEventProperty(AndroidJavaObject propertyConfigurator, string key)
|
||||
{
|
||||
propertyConfigurator.Call("removeEventProperty", key);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e670e8c4e24f54cb3b15b96cba63313b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Microsoft.AppCenter.Unity.Analytics.Internal;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics
|
||||
{
|
||||
public class TransmissionTargetInternal
|
||||
{
|
||||
public static void TrackEvent(AndroidJavaObject transmissionTarget, string eventName)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName);
|
||||
}
|
||||
|
||||
public static void TrackEvent(AndroidJavaObject transmissionTarget, string eventName, int flags)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, null, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, IDictionary<string, string> properties)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
transmissionTarget.Call("trackEvent", eventName, androidProperties);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, EventProperties properties)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, properties.GetRawObject());
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, IDictionary<string, string> properties, int flags)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
transmissionTarget.Call("trackEvent", eventName, androidProperties, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, EventProperties properties, int flags)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, properties.GetRawObject(), flags);
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(AndroidJavaObject transmissionTarget, bool enabled)
|
||||
{
|
||||
var future = transmissionTarget.Call<AndroidJavaObject>("setEnabledAsync", enabled);
|
||||
return new AppCenterTask(future);
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
var future = transmissionTarget.Call<AndroidJavaObject>("isEnabledAsync");
|
||||
return new AppCenterTask<bool>(future);
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetTransmissionTarget(AndroidJavaObject transmissionTargetParent, string transmissionTargetToken, out bool success)
|
||||
{
|
||||
var target = transmissionTargetParent.Call<AndroidJavaObject>("getTransmissionTarget", transmissionTargetToken);
|
||||
success = target != null;
|
||||
return target;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetPropertyConfigurator(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
return transmissionTarget.Call<AndroidJavaObject>("getPropertyConfigurator");
|
||||
}
|
||||
|
||||
public static void Pause(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
transmissionTarget.Call("pause");
|
||||
}
|
||||
|
||||
public static void Resume(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
transmissionTarget.Call("resume");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b4de3e63b6764e059567a9e87feda60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user