update:更新Rustore的Review
This commit is contained in:
@@ -476,20 +476,125 @@ public class SDKManager {
|
||||
|
||||
public static void Review()
|
||||
{
|
||||
ReviewManager manager = ReviewManagerFactory.create(SDKWrapper.getInstance().getContext());
|
||||
Task<ReviewInfo> request = manager.requestReviewFlow();
|
||||
request.addOnCompleteListener(reqTask -> {
|
||||
if (reqTask.isSuccessful()) {
|
||||
ReviewInfo reviewInfo = reqTask.getResult();
|
||||
Activity activity = UnityPlayer.currentActivity;
|
||||
manager.launchReviewFlow(activity, reviewInfo);
|
||||
} else {
|
||||
@ReviewErrorCode int reviewErrorCode = ((ReviewException) request.getException()).getErrorCode();
|
||||
Log.e(TAG,"Review Error code: " + reviewErrorCode);
|
||||
// ReviewManager manager = ReviewManagerFactory.create(SDKWrapper.getInstance().getContext());
|
||||
// Task<ReviewInfo> request = manager.requestReviewFlow();
|
||||
// request.addOnCompleteListener(reqTask -> {
|
||||
// if (reqTask.isSuccessful()) {
|
||||
// ReviewInfo reviewInfo = reqTask.getResult();
|
||||
// Activity activity = UnityPlayer.currentActivity;
|
||||
// manager.launchReviewFlow(activity, reviewInfo);
|
||||
// } else {
|
||||
// @ReviewErrorCode int reviewErrorCode = ((ReviewException) request.getException()).getErrorCode();
|
||||
// Log.e(TAG,"Review Error code: " + reviewErrorCode);
|
||||
// }
|
||||
// });
|
||||
// Runnable
|
||||
RuStoreReview();
|
||||
}
|
||||
//- Rustore相关接口
|
||||
public interface ReviewResultCallback {
|
||||
void onReviewSuccess(JSONObject result);
|
||||
void onReviewError(int code, String msg);
|
||||
}
|
||||
// # 第一步 请求评分request
|
||||
public static void RequestRustoreReView(ReviewResultCallback callback) {
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("action", "ACTION_REQUEST_REVIEW");
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SDKAPI.getIns().thirdExtend(json.toString(), (code, msg) -> {
|
||||
Log.e(TAG, "====>RequestRustoreReView code= " + code + " msg= " + msg);
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
try {
|
||||
result.put("code", code);
|
||||
if (code == SDKCallBack.Extend.EXTEND_CODE_SUCCESS) {
|
||||
Log.e(TAG, "RequestRustoreReView Success: " + msg);
|
||||
//获取成功,msg即为对应的json字符串
|
||||
// 成功时调用回调
|
||||
if (callback != null) {
|
||||
callback.onReviewSuccess(result);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "RequestRustoreReView Failed: " + msg);
|
||||
result.put("thirdExtend_errStr", msg);
|
||||
// 失败时调用回调
|
||||
if (callback != null) {
|
||||
callback.onReviewError(code, msg);
|
||||
}
|
||||
}
|
||||
//code 说明:
|
||||
// 0 : 获取成功
|
||||
// 26012001 : RuStoreNotInstalledException
|
||||
// 26012002 : RuStoreOutdatedException
|
||||
// 26012003 : RuStoreUserUnauthorizedException
|
||||
// 26012004 : RuStoreUserBannedException
|
||||
// 26012005 : RuStoreApplicationBannedException
|
||||
// 26012006 : RuStoreRequestLimitReached
|
||||
// 26012007 : RuStoreReviewExists
|
||||
// 26012008 : RuStoreInvalidReviewInfo
|
||||
// 26012009 : RuStoreException
|
||||
// -1 : 其他未知异常
|
||||
// msg 说明:
|
||||
// 失败时为error msg
|
||||
// UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.RUSTORE_REVIEW_CALLBACK, result.toString());
|
||||
} catch (Exception e) {
|
||||
|
||||
SDKLog.e("SDKManager-RequestRustoreReView-Exception" + e);
|
||||
// UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.RUSTORE_REVIEW_CALLBACK, result.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
// # 第二步,展示评分UI 。请求评分request成功后,调用,且一次成功的request只能调用一次展示
|
||||
public static void LaunchRustoreView(){
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("action", "ACTION_LAUNCH_REVIEW");
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SDKAPI.getIns().thirdExtend(json.toString(), (code, msg) -> {
|
||||
Log.e(TAG, "====>LaunchRustoreView code= " + code + " msg= " + msg);
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
result.put("code", code);
|
||||
if (code == SDKCallBack.Extend.EXTEND_CODE_SUCCESS) {
|
||||
Log.e(TAG, "LaunchRustoreView Success: " + msg);
|
||||
//获取成功,msg即为对应的json字符串
|
||||
// UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.RUSTORE_LAUNCH_REVIEW, result.toString());
|
||||
|
||||
} else {
|
||||
Log.e(TAG, "LaunchRustoreView Failed: " + msg);
|
||||
result.put("thirdExtend_errStr", msg);
|
||||
}
|
||||
// UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.RUSTORE_LAUNCH_REVIEW, result.toString());
|
||||
} catch (Exception e) {
|
||||
|
||||
SDKLog.e("SDKManager-LaunchRustoreReView-Exception" + e);
|
||||
// UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.RUSTORE_LAUNCH_REVIEW, result.toString());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
public static void RuStoreReview(){
|
||||
|
||||
RequestRustoreReView(new ReviewResultCallback() {
|
||||
@Override
|
||||
public void onReviewSuccess(JSONObject result) {
|
||||
LaunchRustoreView();
|
||||
}
|
||||
@Override
|
||||
public void onReviewError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void FBShareLink(String title, String content, String url)
|
||||
{
|
||||
Log.e(TAG,"FBShareLink : " + title + " " + content + " " + url);
|
||||
|
||||
Reference in New Issue
Block a user