Comments (11)
How was this solved? Please share. Thank you!
from hms-unity-plugin.
How was this solved? Please share. Thank you!
Had to uncomment the contents of ShopItem.cs and ShopManager.cs files. Just select all and uncomment once (just once because there are some other functions that can still remain commented, SetNoAds and SetPremium that I'm not using). Then, changed the IapManager references to IapDemoManager inside ShopManager.cs and ShopItem.cs just to make it compile. So far it should at least compile.
In order to make the build, you have to set the correct reference to the scripts within the scene (they may be missing). The Shop prefab is the one with the ShopManager.cs and all the ProductN are the ones with the ShopItem.cs. Then you have to set the productID for each product (I just tried with one product) to the ones you set up in your huawei console.
And then you'll want to debug the ProductInfoList and check it's not empty when calling the BuyProduct function inside IapDemoManager.cs. I had to add some safety checks because it crashed without them.
In my case, the ProductInfoList didn't get populated after the first login at the Start function of the IapDemoManager.cs. I believe it was because the login failed and the LoadStore didn't get called or something. It required a manual Sign In button press to load the product data into the ProductInfoList.
Hope it helps.
[edit] And of course, set the build number higher than the build number of the apk currently in the store (if you have one). Otherwise the sandbox mode won't be triggered with the test accounts and the app will try to make real purchases instead of test ones.
from hms-unity-plugin.
Would be great if someone would fix the IAP demo.
from hms-unity-plugin.
I will reopen this because it is valuable information for us to fix the demos. Thanks a lot for the feedback!
from hms-unity-plugin.
seem still broken, i see in red
ProductInfo productInfo = iapManager.GetProductInfo(productID);
inside Shopitem.cs as this method dont exist in IAPManager
from hms-unity-plugin.
the demo still without working, for some reason the authentication manager is not called. and the iapManager still empty.
from hms-unity-plugin.
yes you have lots of extra works uncomenting samples codes and adding one controler script. so 90 % of code is in, the 10% is not difficult to get on tutorials try google. but it would be great to have it fixed here.
from hms-unity-plugin.
For those of you having trouble, all IapManager references should be changed to IapDemoManager (IapManager should not be used anymore on this demo).
from hms-unity-plugin.
I update the project with the last unity.package, and the follow line of code inside the AccountManager.cs does not work:
authService = DefaultAuthService;
this is the error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine._AndroidJNIHelper.GetSignature (System.Object obj) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1510)
UnityEngine._AndroidJNIHelper.GetSignature (System.Object[] args) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1537)
UnityEngine._AndroidJNIHelper.GetConstructorID (System.IntPtr jclass, System.Object[] args) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:1343)
UnityEngine.AndroidJNIHelper.GetConstructorID (System.IntPtr jclass, System.Object[] args) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJNI.bindings.cs:134)
UnityEngine.AndroidJavaObject._AndroidJavaObject (System.String className, System.Object[] args) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:356)
UnityEngine.AndroidJavaObject..ctor (System.String className, System.Object[] args) (at /Users/builduser/buildslave/unity/build/Modules/AndroidJNI/AndroidJava.cs:217)
HuaweiMobileServices.Utils.JavaObjectWrapper..ctor (System.String javaObjectCanonicalName, System.Object[] args) (at <48d7bb68e1d14c9893e6fd7c425224d3>:0)
HuaweiMobileServices.Id.Scope..ctor (System.String uri) (at <48d7bb68e1d14c9893e6fd7c425224d3>:0)
HuaweiMobileServices.Id.HuaweiIdAuthParams..cctor () (at <48d7bb68e1d14c9893e6fd7c425224d3>:0)
Rethrow as TypeInitializationException: The type initializer for 'HuaweiMobileServices.Id.HuaweiIdAuthParams' threw an exception.
HmsPlugin.AccountManager.OnEnable () (at Assets/Huawei/Scripts/Account/AccountManager.cs:36)
UnityEngine.GameObject:SetActive(Boolean)
MenuManager:ShowCurrencyShop() (at Assets/RaccoonRescue/Scripts/GUI/Menu/MenuManager.cs:96)
AnimationManager:BuyGems() (at Assets/RaccoonRescue/Scripts/GUI/AnimationManager.cs:218)
UnityEngine.EventSystems.EventSystem:Update() (at /Applications/Unity/Hub/Editor/2019.2.21f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
from hms-unity-plugin.
According to the error message, it looks like there was an error during HuaweiMobileServices initialization.
Rethrow as TypeInitializationException: The type initializer for 'HuaweiMobileServices.Id.HuaweiIdAuthParams' threw an exception.
Therefore, DefaultAuthService was probably null and you get the null reference exception. I recomend checking wether the initialization was correct or not. Toss a try/catch surrounding the initialization, just to see what happened.
from hms-unity-plugin.
IAP Demo re-designed and it is working.
from hms-unity-plugin.
Related Issues (20)
- Fix crash in HuaweiMobileServices.Base.Status.StartResolutionForResultAsync HOT 8
- Build failure:Plugin with id 'com.huawei.agconnect' not found. HOT 11
- hms ads HOT 3
- not working in 2022.3.8f1 lts HOT 2
- This is a test HOT 1
- NullReferenceException: Failed to load the HMSIAPKitSettings. Please restart Unity Editor HOT 7
- HMS Ads not working in internal build HOT 9
- ADS Not Working in HMS 2.3.4 Unity HOT 5
- Errors during build HOT 3
- 调用SilentSignIn登录返回错误码7400 HOT 2
- This is a test HOT 2
- Help with consent HOT 8
- Developer payload cannot be passed thru PurchaseProduct method HOT 7
- Consumption of purchases in InitializeIAP should be optional HOT 6
- 3.2.5 Version on 2020 Unity version is not compling HOT 5
- 请问有没有要使用这个插件接入华为的防沉迷功能应该怎么做? HOT 15
- HMS Unity not working , create run time error (v2.3.5 - Unity 2019/2020/2021) HOT 12
- Disable 'update plugin' process on consoles HOT 3
- Ads not showing in Unity 2022.2.13 HOT 3
- About App-Ads.txt HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hms-unity-plugin.