using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ios
using System.Runtime.InteropServices;
public class IosBridge : MonoBehaviour {
public static OnSdkLoginInfo sdkLoginInfo = null;
public static OnSdkLoginInfo sdkPayResultInfo = null;
public static OnSdkRealNameSuccess sdkRealNamaeSuccess = null; //实名验证结果回调
public static bool bUpdateVersion = false; // 是否已经检查跟新完了 ?
public static bool bLinkShenHe = false; // 是否去链接审核服 ?(ios 里面会去判断,如果客户端版本号比服务器版本号高,那么就去连接审核服)
public static bool bInfo = false;
public string mlinkInfo = "";
public static string mChannelCode = "";
public static string mChannelCodeURL = ""; // 该链接用于返回一个 fb3 , fb2, s01
public static string mIMEI = "";
public static string mPlatform = "";
public static string mSdkAccount = "";
public static string mPowerInfo = "";
public static string mRealNameVerifyResult = ""; // 实名验证结果
public static string mVersion = ""; // 版本号
public static string mCDNUrl = ""; // CDNUrl
public static string mServerUrl = ""; // ServerUrl
public static string mPushClientId = ""; // 个推uid
public static string mPhoneName = ""; // 机型
public static string mPhoneOS = ""; // 操作系统
// 实名验证
[DllImport("__Internal")]
private static extern void _RealNameVerify();
public static void RealNameVerify()
{
if (Application.platform != RuntimePlatform.OSXEditor)
{
Debug.Log("[c# :] ============================================= RealNameVerify ---");
_RealNameVerify();
}
}
// 获取实名验证结果回调
public static void OnSetRealNameVerifyResult(string str)
{
mRealNameVerifyResult = str;
if (sdkRealNamaeSuccess != null)
{
sdkRealNamaeSuccess(str);
}
}
// 获取版本号
public static void OnGetVersion(string str)
{
mVersion = str;
}
// 登录接口
[DllImport("__Internal")]
private static extern void _showLogin();
public static void showLogin()
{
if (Application.platform != RuntimePlatform.OSXEditor)
{
Debug.Log("[c# :] ============================================= showLogin ---");
_showLogin();
}
}
// 登出接口
[DllImport("__Internal")]
private static extern void _showLogOut();
public static void showLogOut()
{
if (Application.platform != RuntimePlatform.OSXEditor)
{
Debug.Log("[c# :] ============================================= IosBridge.showLogOut ---");
_showLogOut();
}
}
// 支付接口
[DllImport("__Internal")]
private static extern void _pay(float money, string desc, string roleid, int rolelv, string serverid, string notifyURL, string productid);
public static void pay(float money, string desc, string roleid, int rolelv, string serverid, string notifyURL, string productid)
{
if (Application.platform != RuntimePlatform.OSXEditor)
{
Debug.Log(" [c#: ] ============================================= IosBridge.pay ---");
_pay(money, desc, roleid, rolelv, serverid, notifyURL, productid );
}
}
public static string GetChannelCode()
{
Debug.Log(" [c# :] ============================= IosBridge.GetChannelCode: " + mChannelCode);
return mChannelCode;
}
// 获取 获取渠道号的url
public static string GetChannelCodeURL()
{
Debug.Log(" [c# :] ============================= IosBridge.GetChannelCodeURL: " + mChannelCodeURL);
return mChannelCodeURL;
}
// sdk 返回的账号
[DllImport("__Internal")]
private static extern void _GetSdkAccount();
public static string GetSdkAccount()
{
return mSdkAccount;
}
public static string GetIMEI()
{
return mIMEI;
}
// 获取 IOS 的 IMEI
[DllImport("__Internal")]
private static extern void _GetIosPowerInfo();
public static string GetIosPowerInfo()
{
return mPowerInfo;
}
public static string GetPackageChannelPlatform()
{
Debug.Log("[c# ]: ===================== IosBridge.GetPackageChannelPlatform === ");
return mPlatform;
}
// 返回 0:整包跟新提示框, 1:审核服, 2:正常启动
[DllImport("__Internal")]
private static extern void _getLinkInfo();
public static bool BGetLinkInfo()
{
Debug.Log("[c# ]: ===================== IosBridge.BGetLinkInfo === ");
_getLinkInfo();
return false;
}
// 上报角色信息
[DllImport("__Internal")]
private static extern void _UpLoadInfo(string roleName, string roleid, string roleLevel, string srv_id, string srv_name, int mType , int toRoleLv);
public static void UpLoadInfo(string roleName, string roleid, string roleLevel, string srv_id, string srv_name, int mType, int toRoleLv)
{
Debug.Log("[c# ]: ==== IosBridge.UpLoadInfo ====");
_UpLoadInfo(roleName, roleid, roleLevel, srv_id, srv_name, mType , toRoleLv);
}
// ios 调用u3d: 参数1: SdkBridge 为 gameObject
// 参数2: IosCallU3d 为 IosBridge.cs 中的函数
// 参数3: [sendMsg UTF8String] ios 返回值
//【sdk.mm】 UnitySendMessage("SdkBridge", "IosCallU3d", [sendMsg UTF8String])
public void IosCallU3d(string str)
{
sdkLoginInfo(str);
}
// ios 检查完版本跟新后,允许游戏往下执行
public void OnCheckedUpdateVersion(string str) {
Debug.Log("[c# ]: ==== IosBridge.OnCheckedUpdateVersion ====");
bUpdateVersion = true;
}
// ios 版本号比较结果通知(如果)
public void OnSetLinkShenHe(string str) {
Debug.Log("[c# ]: ==== IosBridge.OnSetLinkShenHe ====");
bLinkShenHe = true;
}
public void OnGetIosPowerInfo(string str) {
Debug.Log("[c# ]: ==== IosBridge.OnGetIosPowerInfo ====");
mPowerInfo = str;
}
// sdk 返回的渠道号 fb2
public void OnSetChannelCode(string str){
mChannelCode = str;
}
public void OnSetIMEI(string str){
mIMEI = str;
}
public void OnSetPlatform(string str){
mPlatform = str;
}
public void OnSetSdkAccount(string str){
mSdkAccount = str;
}
public void OnSetChannelCodeURL(string str) {
mChannelCodeURL = str;
}
public void OnSetCDNUrl(string str)
{
mCDNUrl = str;
}
public void OnSetServerUrl(string str)
{
mServerUrl = str;
}
public void OnSetPushClientId(string str)
{
mPushClientId = str;
}
public void OnSetPhoneName(string str)
{
mPhoneName = str;
}
public void OnSetPhoneOS(string str)
{
mPhoneOS = str;
}
//获取个推uid
public static string GetPushClientId()
{
return mPushClientId;
}
//获取手机机型
public static string GetPhoneName()
{
return mPhoneName;
}
//获取操作系统
public static string GetPhoneOS()
{
return mPhoneOS;
}
public static string GetCDNUrl()
{
Debug.Log(" [c# :] ============================= IosBridge.GetCDNUrl: " + mChannelCode);
return mCDNUrl;
}
public static string GetServerUrl()
{
Debug.Log(" [c# :] ============================= IosBridge.GetServerUrl: " + mServerUrl);
return mServerUrl;
}
}
unity3d 与 ios 相互调用 cs 源码
猜你喜欢
转载自blog.csdn.net/jiuzhouhi/article/details/85001355
今日推荐
周排行