예제 #1
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);
     }
 }
예제 #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("");
        }
예제 #3
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);
            }
        }
예제 #4
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);
     }
 }
예제 #5
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);
            }
        }
예제 #6
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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
            }
        }
예제 #10
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);
            }
        }
예제 #11
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);
            }
        }
예제 #12
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);
            }
        }
예제 #13
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);
            }
        }
예제 #14
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);
                }
            }
        }
예제 #15
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);
            }
        }
예제 #16
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);
        }
예제 #17
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);
            }
        }
예제 #18
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);
            }
        }
예제 #19
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);
            }
        }
예제 #20
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);
            }
        }
예제 #21
0
        /// <summary>
        /// 删除标签,删除设置过的标签
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        /// <param name="tag">标签</param>
        public static void DeleteTag(string channel, string tag)
        {
            try
            {
                MSDKLog.Log("DeleteTag channel=" + channel + " tag=" + tag);
#if UNITY_EDITOR
#else
                deleteTagAdapter(channel, tag);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("DeleteTag with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #22
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);
            }
        }
예제 #23
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);
            }
        }
예제 #24
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);
            }
        }
예제 #25
0
        /// <summary>
        /// 注册推送,完成之后会返回设备的 token,用于后台推送标识设备唯一性
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        /// <param name="account"> 用户的帐号(别名)。上报用户的帐号(别名),以便支持按帐号(别名)推送。如果填 NULL,使用登录成功的openID 作为账号(别名) </param>
        public static void RegisterPush(string channel, string account = "")
        {
            try
            {
                MSDKLog.Log("RegisterPush channel=" + channel + " account=" + account);
#if UNITY_EDITOR
#else
                registerPushAdapter(channel, account);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("RegisterPush with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #26
0
        /// <summary>
        /// 注销设备,此台设备不接收推送
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        public static void UnregisterPush(string channel)
        {
            try
            {
                MSDKLog.Log("UnregisterPush channel=" + channel);
#if UNITY_EDITOR
#else
                unregisterPushAdapter(channel);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("UnregisterPush with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #27
0
 private void Update()
 {
     lock (queueLock) {
         if (resultQueue.Count <= 0)
         {
             return;
         }
         try {
             var arg = resultQueue.Dequeue();
             ParaseDelegate(arg);
         } catch (Exception e) {
             MSDKLog.LogError(e.Message + "   \n" + e.StackTrace);
         }
     }
 }
예제 #28
0
        /// <summary>
        /// 获取与群的关系
        /// </summary>
        /// <param name="targetID">微信填写 工会ID; 手Q 填写群号</param>
        /// <param name="extraJson">扩展字段,默认为空</param>
        public static void GetGroupRelation(string targetID, string extraJson = "")
        {
            try
            {
                MSDKLog.Log("GetGroupRelation  targetID=" + targetID + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                getGroupRelationAdapter(targetID, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetGroupRelation with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #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);
            }
        }
예제 #30
0
        /// <summary>
        /// 加入群
        /// </summary>
        /// <param name="unionID">工会 ID</param>
        /// <param name="zoneID">游戏区服 ID</param>
        /// <param name="roleID">游戏角色 ID</param>
        /// <param name="groupID">手Q群 ID,手Q使用</param>
        /// <param name="extraJson">扩展字段,默认为空</param>
        public static void JoinGroup(string unionID, string zoneID = "", string roleID = "", string groupID = "", string extraJson = "")
        {
            try
            {
                MSDKLog.Log("JoinGroup  unionID=" + unionID + " zoneID=" + zoneID + " roleID=" + roleID + " groupID=" + groupID + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                joinGroupAdapter(unionID, zoneID, roleID, groupID, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("JoinGroup with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }