public void SetRemoteSettings(GamebaseResponse.Launching.LaunchingInfo launchingInfo) { if (launchingInfo == null || launchingInfo.launching == null || launchingInfo.launching.tcgbClient == null) { return; } var forceRemoteSettings = launchingInfo.launching.tcgbClient.forceRemoteSettings; if (forceRemoteSettings != null) { GamebaseLog.Debug(GamebaseJsonUtil.ToPrettyJsonString(forceRemoteSettings), this); logSetting.Initialize(forceRemoteSettings.log.policy, forceRemoteSettings.log.indicator); GamebaseLog.SetDebugLog(logSetting.IsDebugMode(isDebugMode)); GamebaseLogReport.Instance.Initialize( logSetting.IsIndicatorMode(), forceRemoteSettings.log.appKeyIndicator, forceRemoteSettings.log.appKeyLog); } else { GamebaseLog.Debug("ForceRemoteSettings is null", this); } }
private void GetAccessToken(string providerName, System.Action <WebSocketRequest.RequestVO> callback) { WebSocketRequest.RequestVO requestVO = null; GamebaseResponse.Launching.LaunchingInfo launchingInfo = Gamebase.Launching.GetLaunchingInformations(); if (launchingInfo.launching.app.loginUrls == null || string.IsNullOrEmpty(launchingInfo.launching.app.loginUrls.gamebaseUrl) == true) { #if UNITY_EDITOR GamebaseLog.Error("You need to switch platform the Standalone.", this); #else GamebaseLog.Debug("launchingInfo.launching.standalone is null.", this); #endif callback(requestVO); return; } if (launchingInfo == null) { GamebaseLog.Debug("launchingInfo is null.", this); callback(requestVO); return; } GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.APP.LaunchingIDPInfo launchingIDPInfo = launchingInfo.launching.app.idP["gbid"]; if (launchingIDPInfo == null) { GamebaseLog.Debug("gbid is null.", this); callback(requestVO); return; } string clientID = launchingIDPInfo.clientId; StringBuilder url = new StringBuilder(launchingInfo.launching.app.loginUrls.gamebaseUrl); url.AppendFormat("?clientId={0}", clientID); url.AppendFormat("&snsCd={0}", providerName); url.AppendFormat("&svcUrl={0}", Uri.EscapeDataString(SCHEME_AUTH_LOGIN)); url.AppendFormat("&tokenKind={0}", "SNS"); url.Append("&isMobile=true"); url.Append(MakeProviderAdditionalInfo(providerName)); WebviewAdapterManager.Instance.ShowWebView( url.ToString(), null, (error) => { callback(requestVO); }, new List <string>() { SCHEME_AUTH_LOGIN, SCHEME_WEBVIEW_CLOSE }, (scheme, error) => { WebviewAdapterManager.SchemeInfo schemeInfo = WebviewAdapterManager.Instance.ConvertURLToSchemeInfo(scheme); if (schemeInfo.scheme.Equals(SCHEME_AUTH_LOGIN) == true) { var idPAccessToken = string.Empty; if (schemeInfo.parameterDictionary.TryGetValue(ACCESS_TOKEN_KEY, out idPAccessToken) == true) { requestVO = AuthMessage.GetIDPLoginMessage(providerName, idPAccessToken); WebviewAdapterManager.Instance.CloseWebView(); } } else if (schemeInfo.scheme.Equals(SCHEME_WEBVIEW_CLOSE) == true) { WebviewAdapterManager.Instance.CloseWebView(); } }); }
public void RequestPurchase(long itemSeq, int handle) { GamebaseCallback.GamebaseDelegate <GamebaseResponse.Purchase.PurchasableReceipt> puechaseCallback = (purchasableReceipt, error) => { GamebaseResponse.Launching.LaunchingInfo launchingInfo = GamebaseLaunchingImplementation.Instance.GetLaunchingInformations(); if (Gamebase.IsSuccess(error) == true) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_SUCCESS, GamebaseIndicatorReportType.LogLevel.INFO, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }); } else { if (error.code == GamebaseErrorCode.PURCHASE_USER_CANCELED) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_CANCELED, GamebaseIndicatorReportType.LogLevel.DEBUG, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }, error, true); } else { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_FAILED, GamebaseIndicatorReportType.LogLevel.DEBUG, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }, error, true); } } var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Purchase.PurchasableReceipt> >(handle); if (callback != null) { callback(purchasableReceipt, error); } GamebaseCallbackHandler.UnregisterCallback(handle); }; if (IsLoggedIn() == false) { puechaseCallback(null, new GamebaseError(GamebaseErrorCode.NOT_LOGGED_IN, Domain)); return; } PurchaseAdapterManager.Instance.RequestPurchase( itemSeq, (receipt, error) => { if (Gamebase.IsSuccess(error) == true) { GamebaseAnalytics.Instance.CompletePurchase(receipt); } else { } puechaseCallback(receipt, error); }); }
private void GetAccessToken(string providerName, System.Action <WebSocketRequest.RequestVO> callback) { WebSocketRequest.RequestVO requestVO = null; GamebaseResponse.Launching.LaunchingInfo launchingInfo = Gamebase.Launching.GetLaunchingInformations(); if (null == launchingInfo.launching.app.loginUrls || true == string.IsNullOrEmpty(launchingInfo.launching.app.loginUrls.gamebaseUrl)) { #if UNITY_EDITOR GamebaseLog.Error("You need to switch platform the Standalone.", this, "GetAccessToken"); #else GamebaseLog.Debug("launchingInfo.launching.standalone is null.", this, "GetAccessToken"); #endif callback(requestVO); return; } if (null == launchingInfo) { GamebaseLog.Debug("launchingInfo is null.", this, "GetAccessToken"); callback(requestVO); return; } GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.APP.LaunchingIDPInfo launchingIDPInfo = launchingInfo.launching.app.idP["gbid"]; if (null == launchingIDPInfo) { GamebaseLog.Debug("gbid is null.", this, "GetAccessToken"); callback(requestVO); return; } string clientID = launchingIDPInfo.clientId; StringBuilder url = new StringBuilder(launchingInfo.launching.app.loginUrls.gamebaseUrl); url.Append("?clientId=").Append(clientID); url.Append("&snsCd=").Append(providerName); url.Append("&svcUrl=").Append(WWW.EscapeURL(SCHEME_AUTH_LOGIN)); url.Append("&tokenKind=").Append("SNS"); WebviewAdapterManager.Instance.ShowWebView( url.ToString(), null, (error) => { callback(requestVO); }, new List <string>() { SCHEME_AUTH_LOGIN }, (scheme, error) => { WebviewAdapterManager.SchemeInfo schemeInfo = WebviewAdapterManager.Instance.ConvertURLToSchemeInfo(scheme); if (true == schemeInfo.parameterDictionary.ContainsKey(ACCESS_TOKEN_KEY)) { var IDPAccessToken = schemeInfo.parameterDictionary[ACCESS_TOKEN_KEY]; requestVO = AuthMessage.GetIDPLoginMessage(providerName, IDPAccessToken); WebviewAdapterManager.Instance.CloseWebView(); } } ); }