Exemplo n.º 1
0
        /// <summary>
        /// 获取模拟登录态
        /// </summary>
        /// <returns>The login data.</returns>
        /// <param name="channel">渠道</param>
        public static string GetLoginData(int methodId, string channel = "", string subChannel = "")
        {
            string filePath = dataFilePath + channel + subChannel + "LoginData.txt";
            string data     = GetData(filePath);

            if (!string.IsNullOrEmpty(channel) && !string.IsNullOrEmpty(data))
            {
                WriteLoginData(data);
            }
            if (!string.IsNullOrEmpty(data))
            {
                try
                {
                    // 伪造登录,使用特殊Token,到后台校验,目前token是所有游戏一样,后续改造
                    MSDKLoginRet ret = new MSDKLoginRet(data);
                    ret.MethodNameId = methodId;
                    ret.Token        = "MSDKLOGINMOCKER_51433213c2e72a6304fb805b10a2201d";
                    data             = ret.ToString();
                }
                catch (System.Exception e)
                {
                    MSDKLog.Log("Wrong MSDKLoginRet data " + data);
                    MSDKLog.Log(e.StackTrace);
                }
            }

            return(data);
        }
Exemplo n.º 2
0
        public static string OnMSDKRet(int methodId, string ret)
        {
            var argsWrapper = new RetArgsWrapper(methodId, ret);

            MSDKLog.Log("OnMSDKRet, the methodId is ( " + methodId + " )  ret=\n " + ret);
#if GCLOUD_MSDK_WINDOWS
#else
            if (methodId == (int)MSDKMethodNameID.MSDK_WEBVIEW_JS_CALL)  //JS回调在webview线程中,不走unity主线程
            {
                ParaseDelegate(argsWrapper);
                return("");
            }
            if (methodId == (int)MSDKMethodNameID.MSDK_CRASH_CALLBACK_EXTRA_MESSAGE ||
                methodId == (int)MSDKMethodNameID.MSDK_CRASH_CALLBACK_EXTRA_DATA)
            {
                string result = SynchronousDelegate(argsWrapper);
                return(result);
            }
            if (methodId == (int)MSDKMethodNameID.MSDK_LOGIN_GETLOGINRESULT)   // GetLoginResult 改为同步接口,不会出现这种回调
            {
                MSDKLog.LogError("MSDK_LOGIN_GETLOGINRESULT");
                return("");
            }
            if (methodId == (int)MSDKMethodNameID.MSDK_LOGIN_WAKEUP)
            {
                wakeUpLoginRet = ret;
            }
#endif
            lock (queueLock) {
                resultQueue.Enqueue(argsWrapper);
            }
            return("");
        }
Exemplo n.º 3
0
 public static void SetAutoReportLogLevel(int level)
 {
     try
     {
         if (level == 5) //BuglyLogLevelVerbose
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.Log);
         }
         else if (level == 4) //BuglyLogLevelDebug
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogDebug);
         }
         else if (level == 3) //BuglyLogLevelInfo
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogInfo);
         }
         else if (level == 2) //BuglyLogLevelWarn
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogWarning);
         }
         else if (level == 1) //BuglyLogLevelError
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogError);
         }
         else if (level == 0) //BuglyLogLevelSilent
         {
             BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogException);
             BuglyAgent.ConfigDebugMode(false);
         }
     }
     catch (Exception ex)
     {
         MSDKLog.LogError("SetAutoReportLogLevel with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// MSDK init,游戏开始的时候设置
        /// </summary>
        public static void Init()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            if (isDebug)
            {
                MSDKLog.SetLevel(MSDKLog.Level.Log);
            }
            else
            {
                MSDKLog.SetLevel(MSDKLog.Level.Error);
            }

            MSDKMessageCenter.Instance.Init();

#if GCLOUD_MSDK_WINDOWS
#elif UNITY_EDITOR || UNITY_STANDALONE_WIN
#else
            MSDKCrash.InitCrash();
#endif
            MSDKLog.Log("MSDK initialed !");
        }
Exemplo n.º 5
0
        public void Init()
        {
#if GCLOUD_MSDK_WINDOWS
            setUnityCallback(OnMSDKRet);
#elif !(UNITY_EDITOR || UNITY_STANDALONE)
            setUnityCallback(OnMSDKRet);
#endif
            MSDKLog.Log("MSDK Init, set unity callback");
        }
Exemplo n.º 6
0
        /// <summary>
        /// 游戏主动获取wakeup的回调
        /// </summary>
        /// <returns>The wake up login ret.</returns>
#if GCLOUD_MSDK_WINDOWS
#else
        public MSDKLoginRet GetWakeUpLoginRet()
        {
            MSDKLog.Log("GetWakeUpLoginRet, wakeUpLoginRet= " + wakeUpLoginRet);
            if (!string.IsNullOrEmpty(wakeUpLoginRet))
            {
                return(new MSDKLoginRet(wakeUpLoginRet));
            }
            return(null);
        }
Exemplo n.º 7
0
        public static void Init()
        {
#if UNITY_ANDROID
            BuglyAgent.ConfigCrashReporter(1, 1);
#endif
            BuglyAgent.ConfigDebugMode(MSDK.isDebug);
            BuglyAgent.EnableExceptionHandler();

            MSDKLog.Log("InitCrash of Bugly finished");
        }
Exemplo n.º 8
0
        private static string GetData(string filePath)
        {
            if (File.Exists(filePath))
            {
                return(File.ReadAllText(filePath));
            }
            MSDKLog.Log("File Not Exist, " + filePath);
            File.Create(filePath);

            return(string.Empty);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 中控相关,打开中控WebView,目前支持国内渠道,海外渠道暂不支持。
        /// </summary>
        /// <param name="jsonStr">中控下发的json string</param>
        public static void OpenPrajnaWebView(string jsonStr)
        {
            try {
                MSDKLog.Log("OpenPrajnaWebView");
#if UNITY_EDITOR
#else
                openPrajnaWebViewAdapter(jsonStr);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("OpenPrajnaWebView with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 卸载MSDK
 /// </summary>
 public static void UnInstall()
 {
     try
     {
         MSDKLog.Log("UnInstall");
         unInstallAdapter();
     }
     catch (Exception ex)
     {
         MSDKLog.LogError("UnInstall with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 设置分数
        /// </summary>
        /// <param name="board"></param>
        /// <param name="score"></param>
        /// <param name="channel"></param>
        /// <param name="extraJson"></param>
        public static void SetScore(string board, int score, string channel = "", string extraJson = "")
        {
            try {
                MSDKLog.Log("SetScore board=" + board + " score=" + score + " channel=" + channel + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                setScoreAdapter(board, score, channel, extraJson);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("SetScore with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 展示排行榜
        /// </summary>
        /// <param name="board">Board.</param>
        /// <param name="channel">Channel.</param>
        /// <param name="extraJson">extraJson.</param>
        public static void ShowLeaderBoard(string board, string channel = "", string extraJson = "")
        {
            try {
                MSDKLog.Log("ShowLeaderBoard board=" + board + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                showLeaderBoardAdapter(board, channel, extraJson);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("ShowLeaderBoard with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 设置PushToken,可选接口,一般向Ajust、AppsFlyer插件设置firebase token,用于卸载追踪
        /// </summary>
        /// <param name="pushToken">push token</param>
        public static void SetPushToken(string pushToken)
        {
            try {
                MSDKLog.Log("SetPushToken pushToken=" + pushToken);
#if UNITY_EDITOR
#else
                reportSetPushTokenAdapter(pushToken);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("SetPushToken with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 删除指定本地推送
        /// </summary>
        /// <param name="localNotification">本地推送消息结构体</param>
        public static void DeleteLocalNotifications(string key)
        {
            try {
                MSDKLog.Log("DeleteLocalNotification:" + key);
#if UNITY_EDITOR
#else
                deleteLocalNotificationsAdapter("", key);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("DeleteLocalNotifications with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 显示应用内评分,支持iOS
        /// </summary>
        public static void ShowRatingAlert()
        {
            try {
                MSDKLog.Log("ShowRatingAlert");
#if UNITY_EDITOR
#else
                showRatingAlertAdapter();
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("OpenPrajna with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 解锁成就
        /// </summary>
        /// <param name="achieve"></param>
        /// <param name="count"></param>
        /// <param name="channel"></param>
        /// <param name="extraJson"></param>
        public static void UnlockAchievement(string achieve, double count, string channel = "", string extraJson = "")
        {
            try {
                MSDKLog.Log("UnlockAchievement board=" + achieve + " score=" + count + " channel=" + channel + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                unlockAchievementAdapter(achieve, count, channel, extraJson);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("UnlockAchievement with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 中控相关,上报Prajna serinal number,目前支持国内渠道,海外渠道暂不支持。
        /// </summary>
        /// <param name="serialNumber">中控下发的serialNumber</param>
        public static void ReportPrajna(string serialNumber)
        {
            try {
                MSDKLog.Log("ReportPrajna");
#if UNITY_EDITOR
#else
                reportPrajnaAdapter(serialNumber);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("OpenPrajna with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 展示成就榜
        /// </summary>
        /// <param name="channel">Channel.</param>
        /// <param name="extraJson">extraJson.</param>
        public static void ShowAchievement(string channel = "", string extraJson = "")
        {
            try {
                MSDKLog.Log("ShowAchievement channel=" + channel + " extra=" + extraJson);
#if UNITY_EDITOR
#else
                showAchievementAdapter(channel, extraJson);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("ShowAchievement with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 添加前台可显示的本地推送
        /// </summary>
        /// <param name="key">设置通知参数时userInfo指定的key</param>
        public static void AddLocalNotificationAtFront(MSDKLocalNotification localNotification)
        {
            try {
                string localNotificationJson = MiniJSON.Json.Serialize(localNotification);
                MSDKLog.Log("AddLocalNotificationAtFront channel=" + "" + " localNotificationJso= " + localNotificationJson);
#if UNITY_EDITOR
#else
                addLocalNotificationAtFrontAdapter("", localNotificationJson);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("AddLocalNotificationAtFront with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 20
0
        //Bugly 设置自动上报等级
        public static void SetAutoReportLogLevel(int level)
        {
            MSDKLog.Log("SetAutoReportLogLevel, level= " + Convert.ToString(level));
            bool crashEnable = MSDKTools.GetConfig("CRASH_REPORT_ENABLE", false);

            if (!crashEnable)
            {
                return;
            }
            string crashChannel = MSDKTools.GetConfig("CRASH_REPORT_CHANNEL", "Bulgy");

            string[] channels = crashChannel.Split(',');
            for (int i = 0; i < channels.Length; i++)
            {
                if (string.IsNullOrEmpty(channels[i]))
                {
                    continue;
                }
                try
                {
                    // 开启SDK的日志打印,发布版本请务必关闭
                    var assembly   = Assembly.GetExecutingAssembly();
                    var className  = "GCloud.MSDK.MSDK" + channels[i] + "Crash";
                    var methodName = "SetAutoReportLogLevel";

                    UnityEngine.Debug.Log("Set report level, channel= " + className);

                    var type = assembly.GetType(className, true, true);
                    if (type != null)
                    {
                        var methodInfo = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static);
                        if (methodInfo != null)
                        {
                            methodInfo.Invoke(null, new object[] { level });
                        }
                        else
                        {
                            MSDKLog.LogError("cannot get this method, methodName= " + methodName);
                        }
                    }
                    else
                    {
                        MSDKLog.LogError("cannot get type, className= " + className + " methodName= " + methodName);
                    }
                }
                catch (Exception e)
                {
                    MSDKLog.LogError("SetAutoReportLogLevel failed " + e.StackTrace);
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 上报事件
        /// </summary>
        /// <param name="eventName">事件名称</param>
        /// <param name="paramsDic">参数</param>
        /// <param name="spChannels">指定渠道,若无可填空字符串</param>
        /// <param name="isRealTime">是否实时上报</param>
        public static void ReportEvent(string eventName, Dictionary <string, string> paramsDic,
                                       string spChannels = "", bool isRealTime = true)
        {
            try {
                string paramsJson = MiniJSON.Json.Serialize(paramsDic);
                MSDKLog.Log("ReportEvent eventName=" + eventName + " paramsJson=" + paramsJson + " spChannels=" + spChannels + " isRealTime=" + isRealTime);
#if UNITY_EDITOR
#else
                reportEventAdapter(eventName, paramsJson, spChannels, isRealTime);
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("ReportEvent with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 上报初始化接口
        /// </summary>
        /// <param name="channel">初始化渠道列表,以 "," 分割</param>
        /// <returns>返回初始化状态</returns>
        public static bool Init(string channel)
        {
            try {
                MSDKLog.Log("Init channel=" + channel);
#if UNITY_EDITOR
#else
                return(reportInitAdapter(channel));
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("Init with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }

            return(false);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 关闭嵌入式浏览器,暂不支持iOS和内置浏览器
        /// </summary>
        public static void Close()
        {
            try
            {
                MSDKLog.Log("Close");
#if UNITY_EDITOR
#else
                closeAdapter();
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("CallJS with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 获取附近人信息列表
        /// </summary>
        public static void GetNearby( )
        {
            try
            {
                MSDKLog.Log("GetNearby ");
#if UNITY_EDITOR
#else
                getNearbyAdapter();
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetNearby with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// 根据当前登录态,打开对应应用deeplink (deeplink功能的开通和配置请联系各平台)
        /// 具体跳转deeplink。以微信为例,可填写为:
        /// INDEX:跳转微信游戏中心首页
        /// DETAIL:跳转微信游戏中心详情页
        /// LIBRARY:跳转微信游戏中心游戏库
        /// </summary>
        /// <param name="link">具体跳转的link (需要在微信侧先配置好此link)</param>
        public static void OpenDeepLink(string link)
        {
            try
            {
                MSDKLog.Log("OpenDeepLink link=" + link);
#if UNITY_EDITOR
#else
                openDeepLinkAdapter(link);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("OpenDeepLink with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 删除账号
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        /// <param name="tag">账号</param>
        public static void DeleteAccount(string channel, string account)
        {
            try
            {
                MSDKLog.Log("DeleteAccount channel=" + channel + " account=" + account);
#if UNITY_EDITOR
#else
                deleteAccountAdapter(channel, account);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("DeleteAccount with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 通过IP信息获取当前国家
        /// </summary>
        public static void GetIPInfo( )
        {
            try
            {
                MSDKLog.Log("GetIPInfo jsonJsParam=");
#if UNITY_EDITOR
#else
                getIPInfoAdapter();
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetIPInfo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// javascript 调用
        /// </summary>
        /// <param name="jsonJsParam"> javascript json 格式数据入参</param>
        public static void CallJS(string jsonJsParam)
        {
            try
            {
                MSDKLog.Log("CallJS jsonJsParam=" + jsonJsParam);
#if UNITY_EDITOR
#else
                callJSAdapter(jsonJsParam);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("CallJS with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 获取好友列表
        /// </summary>
        /// <param name="page"> 需要获取多少页好友</param>
        /// <param name="count"> 每一页好友的个数 </param>
        /// <param name="isInGame">标识获取的好友是一起玩游戏的好友,还是说普通的好友 </param>
        /// <param name="channel">获取好友的渠道,比如 weChat 、QQ</param>
        /// <param name="subChannel">多渠道时使用,比如 Garena 、乐逗等</param>
        /// <param name="extraJson">扩展字段</param>
        public static void QueryFriends(int page = 0, int count = 0, bool isInGame = true, string channel = "", string subChannel = "", string extraJson = "")
        {
            try
            {
                MSDKLog.Log("QueryFriends page=" + page + " count=" + count + " isInGame=" + isInGame + " channel=" + channel + " subChannel=" + subChannel + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                queryFriendsAdapter(page, count, isInGame, channel, subChannel, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("QueryFriends with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// 清空全部本地推送
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        public static void ClearLocalNotifications(string channel)
        {
            try
            {
                MSDKLog.Log("ClearLocalNotifications channel=" + channel);
#if UNITY_EDITOR
#else
                clearLocalNotificationsAdapter(channel);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("ClearLocalNotifications with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }