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,41 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Distribute.Internal
|
||||
{
|
||||
class DistributeDelegate : AndroidJavaProxy
|
||||
{
|
||||
private DistributeDelegate() : base("com.microsoft.appcenter.distribute.DistributeListener")
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetDelegate()
|
||||
{
|
||||
var distribute = new AndroidJavaClass("com.microsoft.appcenter.distribute.Distribute");
|
||||
distribute.CallStatic("setListener", new DistributeDelegate());
|
||||
}
|
||||
|
||||
bool onReleaseAvailable(AndroidJavaObject activity, AndroidJavaObject details)
|
||||
{
|
||||
if (Distribute.ReleaseAvailable == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var releaseDetails = ReleaseDetailsHelper.ReleaseDetailsConvert(details);
|
||||
return Distribute.ReleaseAvailable.Invoke(releaseDetails);
|
||||
}
|
||||
|
||||
void onNoReleaseAvailable(AndroidJavaObject activity)
|
||||
{
|
||||
if (Distribute.NoReleaseAvailable == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Distribute.NoReleaseAvailable.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5565f155f9c0341da9553fceba984a9b
|
||||
timeCreated: 1499731881
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
// 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;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Distribute.Internal
|
||||
{
|
||||
class DistributeInternal
|
||||
{
|
||||
private static AndroidJavaClass _distribute = new AndroidJavaClass("com.microsoft.appcenter.distribute.Distribute");
|
||||
|
||||
public static void PrepareEventHandlers()
|
||||
{
|
||||
AppCenterBehavior.InitializingServices += Initialize;
|
||||
AppCenterBehavior.Started += StartBehavior;
|
||||
}
|
||||
|
||||
private static void Initialize()
|
||||
{
|
||||
DistributeDelegate.SetDelegate();
|
||||
}
|
||||
|
||||
private static void StartBehavior()
|
||||
{
|
||||
var instance = _distribute.CallStatic<AndroidJavaObject>("getInstance");
|
||||
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
instance.Call("onActivityResumed", activity);
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(bool isEnabled)
|
||||
{
|
||||
var future = _distribute.CallStatic<AndroidJavaObject>("setEnabled", isEnabled);
|
||||
return new AppCenterTask(future);
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync()
|
||||
{
|
||||
var future = _distribute.CallStatic<AndroidJavaObject>("isEnabled");
|
||||
return new AppCenterTask<bool>(future);
|
||||
}
|
||||
|
||||
public static void AddNativeType(List<IntPtr> nativeTypes)
|
||||
{
|
||||
nativeTypes.Add(AndroidJNI.FindClass("com/microsoft/appcenter/distribute/Distribute"));
|
||||
}
|
||||
|
||||
public static void SetInstallUrl(string installUrl)
|
||||
{
|
||||
_distribute.CallStatic("setInstallUrl", installUrl);
|
||||
}
|
||||
|
||||
public static void SetApiUrl(string apiUrl)
|
||||
{
|
||||
_distribute.CallStatic("setApiUrl", apiUrl);
|
||||
}
|
||||
|
||||
public static void NotifyUpdateAction(int updateAction)
|
||||
{
|
||||
var nativeAction = -2;
|
||||
switch((UpdateAction)updateAction) {
|
||||
case UpdateAction.Update:
|
||||
nativeAction = -1;
|
||||
break;
|
||||
case UpdateAction.Postpone:
|
||||
nativeAction = -2;
|
||||
break;
|
||||
}
|
||||
_distribute.CallStatic("notifyUpdateAction", nativeAction);
|
||||
}
|
||||
|
||||
public static void CheckForUpdate()
|
||||
{
|
||||
_distribute.CallStatic("checkForUpdate");
|
||||
}
|
||||
|
||||
public static void StartDistribute()
|
||||
{
|
||||
AppCenterInternal.Start(AppCenter.Distribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1521cae000a1431baeec88f1fc4656b
|
||||
timeCreated: 1499725672
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Distribute.Internal
|
||||
{
|
||||
class ReleaseDetailsHelper
|
||||
{
|
||||
public static ReleaseDetails ReleaseDetailsConvert(AndroidJavaObject details)
|
||||
{
|
||||
var id = details.Call<int>("getId");
|
||||
var version = details.Call<int>("getVersion").ToString();
|
||||
var shortVersion = details.Call<string>("getShortVersion");
|
||||
var releaseNotes = details.Call<string>("getReleaseNotes");
|
||||
var mandatoryUpdate = details.Call<bool>("isMandatoryUpdate");
|
||||
var javaUri = details.Call<AndroidJavaObject>("getReleaseNotesUrl");
|
||||
var uriString = javaUri.Call<string>("toString");
|
||||
var uri = new Uri(uriString);
|
||||
|
||||
return new ReleaseDetails
|
||||
{
|
||||
Id = id,
|
||||
Version = version,
|
||||
ShortVersion = shortVersion,
|
||||
ReleaseNotes = releaseNotes,
|
||||
MandatoryUpdate = mandatoryUpdate,
|
||||
ReleaseNotesUrl = uri
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1301d17c916574ed1a03ba682d73fa10
|
||||
timeCreated: 1499731881
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user