HMS-Core / hms-cordova-plugin

This repo contains all of Cordova HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
100 stars 46 forks source link

HMSConstants.RewardAdEvents... events do not process when RewardAd is running #186

Open kirs26 opened 4 months ago

kirs26 commented 4 months ago

Test code: `

HMSAds.init()

const log = document.querySelector('#log')

const reward = document.querySelector('#reward')
reward.addEventListener('click', async () => {
  log.innerHTML = log.innerHTML + "<br>click-reward"

  var rewardAd = new HMSAds.HMSRewardAd();
  await rewardAd.create("testx9dtjwj8hp");

  rewardAd.on(HMSConstants.RewardAdEvents.REWARDED_LOADED, async() => {
    log.innerHTML = log.innerHTML + "<br>Reward::REWARDED_LOADED"
    console.log("Reward::REWARDED_LOADED")
      await rewardAd.show(true)
  })

  rewardAd.on(HMSConstants.RewardAdEvents.REWARDED_STATUS, (reward) => log.innerHTML = log.innerHTML + "<br>Reward::REWARDED_STATUS")

  rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_CLOSED, () => log.innerHTML = log.innerHTML + "<br>Reward::REWARD_AD_CLOSED")
  rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_FAILED_TO_LOAD, () => log.innerHTML = log.innerHTML + "<br>Reward::REWARD_AD_FAILED_TO_LOAD")
  rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_LOADED, () => log.innerHTML = log.innerHTML + "<br>Reward::REWARD_AD_LOADED")
  rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_OPENED, () => log.innerHTML = log.innerHTML + "<br>Reward::REWARD_AD_OPENED")

  await rewardAd.loadAd()

})

` Test project code is attached hello.zip

Events rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_CLOSED, () => {}) rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_FAILED_TO_LOAD, () => {}) rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_LOADED, () => {}) rewardAd.on(HMSConstants.RewardAdEvents.REWARD_AD_OPENED, () => {})

Never called. Indication true or false when rewardAd.show is called it has no effect

Please tell me what could be the problem?

https://github.com/user-attachments/assets/69c483ff-2d56-478e-bd9a-1df5e756300b