diff --git a/Assets/Scenes/Login-2.unity b/Assets/Scenes/Login-2.unity index 1f64fd701..e9e4e5929 100644 --- a/Assets/Scenes/Login-2.unity +++ b/Assets/Scenes/Login-2.unity @@ -1552,6 +1552,7 @@ RectTransform: - {fileID: 926719788} - {fileID: 394939381} - {fileID: 1085451181} + - {fileID: 1974643440} m_Father: {fileID: 1523843944} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -3451,6 +3452,141 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1825447674} m_CullTransparentMesh: 1 +--- !u!1 &1974643439 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1974643440} + - component: {fileID: 1974643442} + - component: {fileID: 1974643441} + m_Layer: 5 + m_Name: message + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1974643440 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1974643439} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1016403497} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 193.83435, y: -27.2645} + m_SizeDelta: {x: 629.6687, y: 1046.2615} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1974643441 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1974643439} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190335 + m_fontColor: {r: 1, g: 0, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 40 + m_fontSizeBase: 40 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1974643442 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1974643439} + m_CullTransparentMesh: 1 --- !u!1 &1982846006 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Webviewscript.cs b/Assets/Scripts/Webviewscript.cs index 15108e228..bfc767166 100644 --- a/Assets/Scripts/Webviewscript.cs +++ b/Assets/Scripts/Webviewscript.cs @@ -10,6 +10,9 @@ public class Webviewscript : MonoBehaviour { + + public TextMeshProUGUI serverMsg; + public void ShowUrlPopupPositionSize() { GpmWebViewSafeBrowsing.ShowSafeBrowsing("https://arrowserver.vercel.app/auth/google", @@ -25,74 +28,84 @@ private void OnCallback( GpmWebViewCallback.CallbackType callbackType, string data, GpmWebViewError error) +{ + Debug.Log("OnCallback: " + callbackType); + serverMsg.text += "OnCallback: " + callbackType + "\n"; + switch (callbackType) { - Debug.Log("OnCallback: " + callbackType); - switch (callbackType) - { - case GpmWebViewCallback.CallbackType.Open: - if (error != null) - { - Debug.LogFormat("Fail to open WebView. Error:{0}", error); - } - break; - case GpmWebViewCallback.CallbackType.Close: - if (error != null) - { - Debug.LogFormat("Fail to close WebView. Error:{0}", error); - } - break; - case GpmWebViewCallback.CallbackType.PageStarted: - if (string.IsNullOrEmpty(data) == false) - { - Debug.LogFormat("PageStarted Url : {0}", data); - } - break; - case GpmWebViewCallback.CallbackType.PageLoad: - if (string.IsNullOrEmpty(data) == false) - { - Debug.LogFormat("Loaded Page:{0}", data); + case GpmWebViewCallback.CallbackType.Open: + if (error != null) + { + Debug.LogFormat("Fail to open WebView. Error:{0}", error); + // Handle the error here + } + break; + case GpmWebViewCallback.CallbackType.Close: + if (error != null) + { + Debug.LogFormat("Fail to close WebView. Error:{0}", error); + // Handle the error here + } + else + { + // Close the browser here + GpmWebView.Close(); - if (data == "https://arrowserver.vercel.app/auth/protected") - { - StartCoroutine(FetchJsonData(data)); - } - } - break; - case GpmWebViewCallback.CallbackType.MultiWindowOpen: - Debug.Log("MultiWindowOpen"); - break; - case GpmWebViewCallback.CallbackType.MultiWindowClose: - Debug.Log("MultiWindowClose"); - break; - case GpmWebViewCallback.CallbackType.Scheme: - if (error == null) + // Store the data in PlayerPrefs here + StartCoroutine(FetchJsonData(data)); + // PlayerPrefs.SetString("Token", response.token); + // PlayerPrefs.SetString("UserData", JsonUtility.ToJson(response.result)); + } + break; + case GpmWebViewCallback.CallbackType.PageStarted: + if (string.IsNullOrEmpty(data) == false) + { + Debug.LogFormat("PageStarted Url : {0}", data); + } + break; + case GpmWebViewCallback.CallbackType.PageLoad: + if (string.IsNullOrEmpty(data) == false) + { + Debug.LogFormat("Loaded Page:{0}", data); + serverMsg.text += "Loaded Page:{0}" + data + "\n"; + if (data == "https://arrowserver.vercel.app/auth/protected") { - if (data.Equals("USER_ CUSTOM_SCHEME") == true || data.Contains("CUSTOM_SCHEME") == true) - { - Debug.Log(string.Format("scheme:{0}", data)); - } + StartCoroutine(FetchJsonData(data)); + GpmWebView.Close(); } - else + } + break; + case GpmWebViewCallback.CallbackType.MultiWindowOpen: + Debug.Log("MultiWindowOpen"); + break; + case GpmWebViewCallback.CallbackType.MultiWindowClose: + Debug.Log("MultiWindowClose"); + break; + case GpmWebViewCallback.CallbackType.Scheme: + if (error == null) + { + if (data.Equals("https://arrowserver.vercel.app/auth/protected") == true || data.Contains("https://arrowserver.vercel.app/auth/protected") == true) { - Debug.Log(string.Format("Fail to custom scheme. Error:{0}", error)); + serverMsg.text += "scheme:{0}" + data + "\n"; + Debug.Log(string.Format("scheme:{0}", data)); + + StartCoroutine(FetchJsonData(data)); + GpmWebView.Close(); } - break; - case GpmWebViewCallback.CallbackType.GoBack: - Debug.Log("GoBack"); - break; - case GpmWebViewCallback.CallbackType.GoForward: - Debug.Log("GoForward"); - break; - case GpmWebViewCallback.CallbackType.ExecuteJavascript: - Debug.LogFormat("ExecuteJavascript data : {0}, error : {1}", data, error); - break; + } + else + { + Debug.Log(string.Format("Fail to custom scheme. Error:{0}", error)); + // Handle the error here + } + break; #if UNITY_ANDROID case GpmWebViewCallback.CallbackType.BackButtonClose: Debug.Log("BackButtonClose"); break; #endif - } } +} IEnumerator FetchJsonData(string url) { @@ -110,6 +123,7 @@ IEnumerator FetchJsonData(string url) PlayerPrefs.SetString("Token", response.token); Debug.Log(response.result); + serverMsg.text += "data" + response.result + "\n"; PlayerPrefs.SetString("UserData", JsonUtility.ToJson(response.result)); UserData user = JsonUtility.FromJson(PlayerPrefs.GetString("UserData"));