question

AppyNation Ltd. avatar image
AppyNation Ltd. asked

[Unity iOS Plugin] New SDK issues

On importing the new package there are 10 warnings about private fields being assigned but the value not being used.

E.g.

Assets/Plugins/Amazon/AmazonMobileAds/Source/Ad.cs(31,37): warning CS0414: The private field `com.amazon.mas.cpt.ads.Ad.logger' is assigned but its value is never used

On requesting a banner or interstitial there is an exception every time:

InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.List`1+Enumerator[com.amazon.mas.cpt.ads.IDelegator].VerifyState () [0x00000] in :0 at System.Collections.Generic.List`1+Enumerator[com.amazon.mas.cpt.ads.IDelegator].MoveNext () [0x00000] in :0 at com.amazon.mas.cpt.ads.AmazonMobileAdsImpl.FireEvent (System.String jsonMessage) [0x00000] in :0 at com.amazon.mas.cpt.ads.AmazonMobileAdsImpl+AmazonMobileAdsBase.UnityFireEvent (System.String jsonMessage) [0x00000] in :0

mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AppyNation Ltd. avatar image
AppyNation Ltd. answered
Please notify the developers so they can fix these problems.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AppyNation Ltd. avatar image
AppyNation Ltd. answered
It would be really helpful if someone from Amazon could answer this.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered
AppyNation, Based on our investigation, the InvalidOperationException exception is thrown because you are attempting in your code to modify the list of event handlers inside an event handler itself. For instance, when your event handler for the adLoaded event might be trying to deregister itself as an event handler. This is our best guess based on the limited info you provided: stack trace and our investigations in trying to reproduce the issue. A few questions: If you still need to register/unregister event handlers, can you not do it inside an event handler itself? If you try that, can you please confirm whether this solution works for you? If not, can you please provide the Unity version and Xcode version you are using to build as well as the iOS device you use for testing? Can you also please share some sample code illustrating how you are using the plugin? Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AppyNation Ltd. avatar image
AppyNation Ltd. answered
Yes, you are correct, I am removing listeners from a listener. This is not normally a problem, I do this type of thing quite a bit with async ops. I like to have a method that has an action that executes when the op is complete, like this: bool LoadAndShowBanner(System.Action onDone) { Action cleanUp = null; AdLoadedDelegate loaded = (Ad obj)=>{ if(obj.AdType==AdType.FLOATING) { cleanUp(); onDone(true); } }; AdFailedToLoadDelegate failed = (Ad obj)=>{ if(obj.AdType==AdType.FLOATING) { cleanUp(); onDone(false); } }; cleanUp = ()=>{ mobileAds.RemoveAdLoadedListener(loaded); mobileAds.RemoveAdFailedToLoadListener(failed); }; mobileAds.AddAdLoadedListener(loaded); mobileAds.AddAdFailedToLoadListener(failed); var placement = new Placement(); placement.Dock = Dock.TOP; placement.HorizontalAlign = HorizontalAlign.CENTER; placement.AdFit = AdFit.FIT_AD_SIZE; banner = mobileAds.CreateFloatingBannerAd(placement); mobileAds.LoadAndShowFloatingBannerAd(banner); return true; }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AppyNation Ltd. avatar image
AppyNation Ltd. answered
And also please make sure to remove the 10 warnings from the next release. Message was edited by: AppyNation Ltd.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered
Thanks AppyNation Ltd. -- we have captured your feedback and will work to implement a fix / remove those warnings. As for your last message about the warnings, if you are referring to the warnings you mentioned in another thread, I have replied to it here: https://forums.developer.amazon.com/forums/message.jspa?messageID=27947#27947
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AppyNation Ltd. avatar image
AppyNation Ltd. answered
No, I'm talking about warnings in Unity when your code compiles.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered
Yes, that too, we are tracking it to remove warnings for not using the logger variable. Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.