prebid / prebid-mobile-ios

Prebid Mobile SDK for iOS applications
Apache License 2.0
47 stars 89 forks source link

fixed fireEvent() in mraid.js. #942

Open AdviewOpen opened 9 months ago

AdviewOpen commented 9 months ago

we found some ads contents with mraid may remove EventListener in listeners function. for example: function addVchange(){
mraid.isViewable()?viewChangeCB(true):mraid.addEventListener("viewableChange",viewCB);//add cb mraid.addEventListener("viewableChange",viewCB2);//add cb2 } function viewCB(n){ console.log('+++++++ viewCB() ++++++++'); mraid.removeEventListener("viewableChange", viewCB));//remove itself } function viewCB2(n){ console.log('+++++++ viewCB2() ++++++++'); } so, if use currently mraid.js, in viewCB(), listener itself will be removed and next item will be null, that mean viewCB2() will not be triggered, we already found some ads contains like this usage, so we change the mraid.fireEvent(), we make a copy when events needs to be fired, if listener function remove itself, the fireEvent()'s array will not be cracked and keep its original order, then all of EventListners will be triggered correctly. pls review it & check it ,greate thanks.

AdviewOpen commented 9 months ago

Hi,@YuriyVelichkoPI Thx for your reply, and we just want to make a suggestion for integrity of prebid sdk, not a direction, so if your side can offer better solution to fix this issue, we'll glad to see and appreciate for your work. And on android-sdk side, i also pull a request #732, the content is same as this one. We hope the issue can be fixed soon & Great thanks again!