Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cast exception after using AGConnectAuth.GetInstance().RequestVerifyCode #303

Closed
mahmoudHijaziN opened this issue Apr 18, 2022 · 4 comments
Labels
solved Developer confirm that issue solved.

Comments

@mahmoudHijaziN
Copy link

Hey guys,
I am using the latest plugin version 2.2 For Unity 2020.3.32f1 with only Auth service enabled.
After reading the demo/documentation and trying the following code:

VerifyCodeSettings verifyCodeSettings = new VerifyCodeSettings.Builder()
            .Action(VerifyCodeSettings.ACTION_REGISTER_LOGIN)
            .Locale(Locale.GetDefault())
            .SendInterval(60).Build();

AGConnectAuth.GetInstance().RequestVerifyCode(code, const_phone, verifyCodeSettings).AddOnSuccessListener( successResult => {
            LoggingManager.LogDebug("HMSLogin, Request code success");
        }).AddOnFailureListener(failureResult => {
            LoggingManager.LogWarning("HMSLogin, Request code failure: " + failureResult);
        });

the RequestVerifyCode function throws the following exception:

InvalidCastException: Unable to cast object of type 'VerifyCodeResult' to type 'ITask`1'.
      at HuaweiMobileServices.AuthService.AGConnectAuth.RequestVerifyCode (System.String countryCode, System.String phoneNumber, HuaweiMobileServices.AuthService.VerifyCodeSettings settings) [0x00000] in <00000000000000000000000000000000>:0 
      at popup_login.sendHmsAuthSmsCode () [0x00000] in <00000000000000000000000000000000>:0 
      at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0 
      at API+<>c__DisplayClass10_0.<Request>b__0 (System.String json) [0x00000] in <00000000000000000000000000000000>:0 
      at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0 
      at API+<RequestIE>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
      at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 

Any idea how this could be fixed?

Thanks.

@alihan98ersoy alihan98ersoy added investigating We are investigating the current problem bug Something isn't working and removed investigating We are investigating the current problem labels Apr 18, 2022
@alihan98ersoy
Copy link
Collaborator

Hello,
We will fix this issue in the next version. You can use the deprecated method for now.

PhoneAuthProvider.RequestVerifyCode(PhoneCountryCode.text, PhoneNumber.text, verifyCodeSettings)
EmailAuthProvider.RequestVerifyCode( email,  paramVerifyCodeSettings)

Thanks for raising the issue.

@mahmoudHijaziN
Copy link
Author

mahmoudHijaziN commented Apr 19, 2022

Hey, Thanks a lot, it worked properly after using the deprecated method.

However, I suffered from another error while trying out the push SDK:

Could not determine the dependencies of task ':unityLibrary:HMSUnityPushKit.plugin:compileReleaseAidl'.
> Failed to install the following SDK components:
      build-tools;29.0.2 Android SDK Build-Tools 29.0.2
  The SDK directory is not writable (C:\Program Files\Unity\Hub\Editor\2020.3.32f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK)

Should I keep it here or insert it in another issue?

@alihan98ersoy
Copy link
Collaborator

Hello,
It would be cleaner if you open a new issue, but it's up to you.

This problem seems to be a problem with unity rather than the project. But I wonder if you can close unity and open it again, maybe the problem will be solved.

@mahmoudHijaziN
Copy link
Author

Hey, I downloaded Build Tools 29.0.2 from android studio, copied/pasted it into the SDK directory of unity and it worked properly.
Will close the issue since it is working now.

Thanks a lot for the fast reply and help

alihan98ersoy added a commit that referenced this issue Apr 29, 2022
#303 Fixed
Version number increased,
Dll updated
alihan98ersoy added a commit that referenced this issue Apr 29, 2022
Lists of countries and languages ​​in PMS API sorted,
Minor UI fixes in PMS API,
Fixed bug when IAP product identifier consisted of numeric only,
#303 -> Requesting via Email and Phone verification code method(RequestVerifyCode) in AGConnectAuth Fixed.
@alihan98ersoy alihan98ersoy added solved Developer confirm that issue solved. and removed bug Something isn't working labels May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved Developer confirm that issue solved.
Projects
None yet
Development

No branches or pull requests

2 participants