예제 #1
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);
            }
        }
예제 #2
0
        /// <summary>
        /// 加载公告信息
        /// </summary>
        /// <param name="noticeGroup">公告分组,后台填好公告并且分好组就可以对应拉取公告信息</param>
        /// <param name="language">语种</param>
        /// <param name="region">地区,北美、亚太、南美等等</param>
        /// <param name="partition">游戏大区</param>
        /// <param name="extraJson">扩展字段</param>
        public static string LoadNoticeData(string noticeGroup, string language, int region, string partition,
                                            string extraJson = "")
        {
            try {
                MSDKLog.Log("LoadNoticeData noticeGroup=" + noticeGroup + " language=" + language + " region=" + region + " partition=" + partition + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                return(loadNoticeDataAdapter(noticeGroup, language, region, partition, extraJson));
#endif
            } catch (Exception ex) {
                MSDKLog.LogError("LoadNoticeData with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }

            return(null);
        }
예제 #3
0
        private static void UnityEditorLogout()
        {
#if GCLOUD_MSDK_WINDOWS
#else
            string retJson = UnityEditorData.GetLogoutData();
            if (!string.IsNullOrEmpty(retJson))
            {
                MSDKMessageCenter.OnMSDKRet((int)MSDKMethodNameID.MSDK_LOGIN_LOGOUT, retJson);
            }
            else
            {
                MSDKLog.Log("Simulator Logout data is empty.");
            }
#endif
        }
예제 #4
0
 public static void SetUserId(string userId)
 {
     try
     {
         MSDKLog.Log("SetUserId userId = " + userId);
         #if UNITY_EDITOR
         #else
         setUserIdAdapter(userId);
         #endif
     }
     catch (Exception ex)
     {
         MSDKLog.LogError("SetUserId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
     }
 }
예제 #5
0
        private static void UnityEditorConnect(MSDKMethodNameID methodId, string channel = "", string subChannel = "")
        {
#if GCLOUD_MSDK_WINDOWS
#else
            string retJson = UnityEditorData.GetLoginData((int)methodId, channel, subChannel);
            if (!string.IsNullOrEmpty(retJson))
            {
                MSDKMessageCenter.OnMSDKRet((int)methodId, retJson);
            }
            else
            {
                MSDKLog.Log("Simulator data is empty. channel=" + channel);
            }
#endif
        }
예제 #6
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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
            }
        }
예제 #10
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);
            }
        }
예제 #11
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);
            }
        }
예제 #12
0
        /// <summary>
        /// 设置关键数据[键值对],随崩溃信息上报
        /// </summary>
        /// <param name="k"></param>
        /// <param name="v"></param>
        public static void SetUserValue(string k, string v)
        {
            try
            {
                MSDKLog.Log("SetUserValue  key=" + k + " value=" + v);
#if UNITY_EDITOR
#else
                setUserValueAdapter(k, v);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("SetUserValue with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #13
0
        /// <summary>
        /// 获取群状态
        /// </summary>
        /// <param name="unionID">工会 ID,微信只需要该参数</param>
        /// <param name="zoneID">游戏中的区服 ID</param>
        /// <param name="extraJson">扩展字段,默认为空</param>
        public static void GetGroupState(string unionID, string zoneID = "", string extraJson = "")
        {
            try
            {
                MSDKLog.Log("GetGroupState  unionID=" + unionID + " zoneID=" + zoneID + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                getGroupStateAdapter(unionID, zoneID, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetGroupState with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #14
0
        /// <summary>
        /// 获取会长的群列表【qq特有】
        /// </summary>
        public static void GetGroupList()
        {
            try
            {
                MSDKLog.Log("GetGroupList");
#if UNITY_EDITOR
#else
                getGroupListAdapter();
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetGroupList with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #15
0
        /// <summary>
        /// 提醒会长建群【qq特有】
        /// </summary>
        /// <param name="unionID">工会 ID</param>
        /// <param name="zoneID">游戏区服 ID</param>
        /// <param name="roleID">游戏角色 ID</param>
        /// <param name="roleName">游戏角色名称</param>
        /// <param name="leaderOpenID">会长 openID</param>
        /// <param name="leaderRoleID">会长角色 ID</param>
        /// <param name="extraJson">扩展字段,默认为空</param>
        public static void RemindToBindGroup(string unionID, string zoneID, string roleID, string roleName, string leaderOpenID, string leaderRoleID, string extraJson = "")
        {
            try
            {
                MSDKLog.Log("RemindToBindGroup  unionID=" + unionID + " zoneID=" + zoneID + " roleID=" + roleID + " roleName=" + roleName + " leaderOpenID=" + leaderOpenID + " leaderRoleID=" + leaderRoleID + " extraJson=" + extraJson);
#if UNITY_EDITOR
#else
                remindToBindGroupAdapter(unionID, zoneID, roleID, roleName, leaderOpenID, leaderRoleID, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("RemindToBindGroup with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #16
0
        /// <summary>
        /// 修改账号信息接口(verifyCode校验码)
        /// <param name="channel">           【必填】支持"Email","SMS"
        /// <param name="account">           【必填】当前存在的账号
        /// <param name="accountType">       【必填】1- email(5到50个字节),2 - phone
        /// <param name="verifyCode">        【必填】验证码
        /// <param name="verifyCodeModify">  【必填】要修改的账号接收到的验证码
        /// <param name="accountModify">     【必填】要修改的帐号
        /// <param name="accountTypeModify"> 【必填】要修改的账号类似1email,2phone
        /// <param name="areaCodeModify">    【选填】要修改的账号是手机时为必填参数, 这里填写的是手机区号字段
        /// <param name="langType">          【选填】指定发送给用户的验证码短信或邮件所有语言
        /// <param name="areaCode">          【选填】手机登录时为必填参数, 这里填写的是手机区号字段
        /// <param name="extraJson">         【选填】扩展字段,默认为空,会透传到后台
        public static void Modify(string channel, string account, int accountType, int verifyCode, int verifyCodeModify, string accountModify, int accountTypeModify, string areaCodeModify, string langType, string areaCode, string extraJson)
        {
            try
            {
                MSDKLog.Log("Modify channel= " + channel);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                //UnityEditorLogin (MSDKMethodNameID.MSDK_LOGIN_LOGIN, channel, subChannel);
#else
                modifyAdapter(channel, account, accountType, verifyCode, verifyCodeModify, accountModify, accountTypeModify, areaCodeModify, langType, areaCode, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("Modify with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #17
0
        /// <summary>
        /// 新增本地推送
        /// 本地通知的数量是有限制的,最近的本地通知最多只能有64个,超过将被系统忽略
        /// </summary>
        /// <param name="channel">渠道信息,比如 XG,Firebase</param>
        /// <param name="localNotification">本地推送消息结构体</param>
        public static void AddLocalNotification(string channel, MSDKLocalNotification localNotification)
        {
            try
            {
                var localNotificationJson = localNotification.ToString();
                MSDKLog.Log("AddLocalNotification channel=" + channel + " localNotificationJson=" + localNotificationJson);
#if UNITY_EDITOR
#else
                addLocalNotificationAdapter(channel, localNotificationJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("AddLocalNotification with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #18
0
        /// <summary>
        /// UI 绑定
        /// </summary>
        public static void BindUI(string extraJson = "")
        {
            try
            {
                MSDKLog.Log("BindUI");
#if UNITY_EDITOR
                //UnityEditorLogin (MSDKMethodNameID.MSDK_LOGIN_LOGINWITHCONFIRMCODE);
#else
                bindUIAdapter(extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("LoginWithConfirmCode with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #19
0
        /// <summary>
        /// 发送群消息【微信特有】
        /// </summary>
        /// <param name="groupMessage">群消息</param>
        /// <param name="unionID">工会 ID</param>
        public static void SendGroupMessage(MSDKGroupMessage groupMessage, string unionID)
        {
            try
            {
                var groupMessageJson = groupMessage.ToString();
                MSDKLog.Log("SendGroupMessage  groupMessageJson=" + groupMessageJson + " unionID=" + unionID);
#if UNITY_EDITOR
#else
                sendGroupMessageAdapter(groupMessageJson, unionID);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("SendGroupMessage with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #20
0
        /// <summary>
        ///  转短链
        /// </summary>
        /// <returns><c>true</c>, if short URL was converted, <c>false</c> otherwise.</returns>
        /// <param name="url">目标 URL</param>
        /// <param name="typeMark">url类型标记,支持A-Z中26个大写英文字母,与open管理后台相对应。获取短链跳转时,通过此参数获取正确的404跳转地址。默认值:A</param>
        public static bool ConvertShortUrl(string url, string typeMark = "A")
        {
            try
            {
                MSDKLog.Log("ConvertShortUrl url=" + url + " typeMark=" + typeMark);
#if UNITY_EDITOR
#else
                return(convertShortUrlAdapter(url, typeMark));
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("ConvertShortUrl with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
            return(false);
        }
예제 #21
0
        /// <summary>
        /// 用户注册接口(生成帐号及token)
        /// <param name="channel">         【必填】支持"Email","SMS"
        /// <param name="account">         【必填】注册的帐号
        /// <param name="password">        【必填】登录密码
        /// <param name="accountType">       【必填】1- email(5到50个字节),2 - phone
        /// <param name="verifyCode">      【选填】验证码
        /// <param name="langType">      【选填】指定发送给用户的验证码短信或邮件所有语言
        /// <param name="areaCode">        【选填】手机渠道时为国际区号,邮箱渠道可直接填""
        /// <param name="extraJson">       【选填】扩展字段,默认为空,会透传到后台
        public static void ResetPassword(string channel, string account, string password, int accountType, int verifyCode, string langType, string areaCode = "86", string extraJson = "")
        {
            try
            {
                MSDKLog.Log("ResetPassword channel= " + channel);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                //UnityEditorLogin (MSDKMethodNameID.MSDK_LOGIN_LOGIN, channel, subChannel);
#else
                resetPasswordAdapter(channel, account, password, accountType, verifyCode, langType, areaCode, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("ResetPassword with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #22
0
        /// <summary>
        /// 绑定关联指定渠道
        /// </summary>
        /// <param name="channel">渠道信息,比如“WeChat”、“QQ”、“Facebook”.</param>
        /// <param name="permissions">登录授权权限列表.</param>
        /// <param name="subChannel">子渠道.</param>
        /// <param name="extraJson">Extra json.</param>
        public static void Bind(string channel, string permissions = "", string subChannel = "", string extraJson = "")
        {
            try
            {
                MSDKLog.Log("Bind channel=" + channel + " permissions=" + permissions + " subChannel=" + subChannel + " extraJson=" + extraJson);
#if GCLOUD_MSDK_WINDOWS
#elif UNITY_EDITOR || UNITY_STANDALONE_WIN
#else
                bindAdapter(channel, permissions, subChannel, extraJson);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("Bind with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #23
0
        /// <summary>
        ///
        /// 检查app 是否安装。安卓传packageName,
        /// iOS可以传URLScheme,或者传渠道名称比如"WeChat","QQ"
        /// </summary>
        /// <returns><c>true</c>, if app installed was installed, <c>false</c> otherwise.</returns>
        /// <param name="channel">Channel.</param>
        public static bool IsAppInstalled(string channel, string extra = "")
        {
            try
            {
                MSDKLog.Log("IsAppInstalled channel=" + channel);
#if UNITY_EDITOR
#else
                return(isAppInstalledAdapter(channel, extra));
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("IsAppInstalled with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
            return(false);
        }
예제 #24
0
        /// <summary>
        /// 自定义日志打印接口,用于记录一些关键的业务调试信息, 可以更全面地反应APP发生崩溃或异常的上下文环境.
        /// </summary>
        /// <param name="level">日志级别,0-silent, 1-error,2-warning,3-inifo,4-debug,5-verbose</param>
        /// <param name="tag">日志模块分类</param>
        /// <param name="log">日志内容</param>
        public static void LogInfo(MSDKCrashLevel level, string tag, string log)
        {
            try
            {
                int intLevel = (int)level;
                MSDKLog.Log("LogInfo  level=" + intLevel + " tag=" + tag + " log=" + log);
#if UNITY_EDITOR
#else
                logInfoAdapter(intLevel, tag, log);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("LogInfo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #25
0
        /// <summary>
        /// 取消关联(connect)
        /// </summary>
        /// <param name="channel">渠道信息,比如目前只有Kwai渠道</param>
        public static void Unconnect(string channel)
        {
            try
            {
                MSDKLog.Log("unconnect channel= " + channel);
#if GCLOUD_MSDK_WINDOWS
#elif UNITY_EDITOR || UNITY_STANDALONE_WIN
#else
                unconnectAdapter(channel);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("unconnect with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #26
0
        /// <summary>
        /// 添加好友,目前只有QQ支持该功能
        /// </summary>
        /// <param name="info">消息结构体,包含需要添加的好友的个人信息</param>
        /// <param name="channel">渠道,比如QQ</param>
        public static void AddFriend(MSDKFriendReqInfo info, string channel = "")
        {
            try
            {
                var infoJson = info.ToString();
                MSDKLog.Log("AddFriend infoJson=" + infoJson + " channel=" + channel);
#if UNITY_EDITOR
#else
                addFriendAdapter(infoJson, channel);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("AddFriend with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #27
0
 internal static void OnFriendQueryFriend(string json)
 {
     MSDKLog.Log("OnFriendQueryFriend json= " + json);
     if (QuereyFriendEvent != null)
     {
         var ret = new MSDKFriendRet(json);
         try {
             QuereyFriendEvent(ret);
         } catch (Exception e) {
             MSDKLog.LogError(e.StackTrace);
         }
     }
     else
     {
         MSDKLog.LogError("No callback for QuereyFriendEvent !");
     }
 }
예제 #28
0
        /// <summary>
        /// 获取用 URL 编码之后的链接
        /// </summary>
        /// <param name="url">链接</param>
        /// <returns>返回 URL 编码之后的链接</returns>
        public static string GetEncodeUrl(string url)
        {
            try
            {
                MSDKLog.Log("GetEncodeUrl url=" + url);
#if UNITY_EDITOR
#else
                return(getEncodeUrlAdapter(url));
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("GetEncodeUrl with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }

            return(null);
        }
예제 #29
0
 /// //----callabck----------
 internal static void OnGameRet(string json)
 {
     MSDKLog.Log("OnGameRet  json= " + json);
     if (GameBaseRetEvent != null)
     {
         var ret = new MSDKBaseRet(json);
         try {
             GameBaseRetEvent(ret);
         } catch (Exception e) {
             MSDKLog.LogError(e.StackTrace);
         }
     }
     else
     {
         MSDKLog.LogError("No callback for GameBaseRetEvent !");
     }
 }
예제 #30
0
        /// <summary>
        /// 打开指定网页
        /// </summary>
        /// <param name="url">网络链接</param>
        /// <param name="screenType">1 默认 2 竖屏 3 横屏 </param>
        /// <param name="isFullScreen">是否全屏</param>
        /// <param name="isUseURLEcode">使用 URL 编码方式,处理非 UTF-8 的字符</param>
        /// <param name="extraJson">扩展字段</param>
        /// <param name="isBrowser">使用系统自带的浏览器打开链接</param>
        public static void OpenUrl(string url, MSDKWebViewOrientation screenType = MSDKWebViewOrientation.Auto, bool isFullScreen = false,
                                   bool isUseURLEcode = true, string extraJson = "", bool isBrowser = false)
        {
            try
            {
                MSDKLog.Log("OpenUrl url=" + url + " screenType=" + screenType + " isFullScreen=" + isFullScreen + " isUseURLEcode=" + isUseURLEcode
                            + " extraJson=" + extraJson + " extraJson=" + extraJson + " isBrowser=" + isBrowser);
#if UNITY_EDITOR
#else
                openUrlAdapter(url, (int)screenType, isFullScreen, isUseURLEcode, extraJson, isBrowser);
#endif
            }
            catch (Exception ex)
            {
                MSDKLog.LogError("OpenUrl with unknown error = \n" + ex.Message + "\n" + ex.StackTrace);
            }
        }