YoYoGames / GMEXT-IronSource

Repository for GameMaker's IronSource Extension
Other
1 stars 1 forks source link

ironsource_rewarded_video_init (NOT MANUAL) is missing #13

Open romhaviv opened 1 month ago

romhaviv commented 1 month ago

as described in IronSource docs, there's a difference between LevelPlayRewardedVideoManualListener and LevelPlayRewardedVideoListener see: https://developers.is.com/ironsource-mobile/android/rewarded-video-integration-android/ and https://developers.is.com/ironsource-mobile/android/rewarded-video-manual-integration-android/

seems like LevelPlayRewardedVideoListener is missing atm.

I suggest changing current ironsource_rewarded_video_init to ironsource_rewarded_video_manual_init and adding it like:

public void ironsource_rewarded_video_init() 
    {
        IronSource.setLevelPlayRewardedVideoListener(new LevelPlayRewardedVideoListener() {

            // Indicates that there's an available ad. 
            // The adInfo object includes information about the ad that was loaded successfully
            // Use this callback instead of onRewardedVideoAvailabilityChanged(true)
            @Override
            public void onAdAvailable(AdInfo adInfo) {
                int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
                RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_availability_changed");
                RunnerJNILib.DsMapAddDouble(dsMapIndex,"available", 1.0);
                RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            // Indicates that no ads are available to be displayed 
            // Use this callback instead of onRewardedVideoAvailabilityChanged(false) 
            @Override
            public void onAdUnavailable() {
                int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
                RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_availability_changed");
                RunnerJNILib.DsMapAddDouble(dsMapIndex,"available", 0.0);
                RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            @Override
            public void onAdOpened(AdInfo adInfo)
            {
            int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
            RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_opened");
            RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            @Override
            public void onAdClosed(AdInfo adInfo)
            {
            int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
            RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_closed");
            RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            @Override
            public void onAdRewarded(Placement placement, AdInfo adInfo)
            {
            int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
            RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_rewarded");
            RunnerJNILib.DsMapAddString(dsMapIndex, "reward_name", placement.getRewardName());
            RunnerJNILib.DsMapAddDouble(dsMapIndex, "reward_amount", (double)placement.getRewardAmount());
            RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            @Override
            public void onAdShowFailed(IronSourceError error, AdInfo adInfo)
            {
            int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
            RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_show_failed");
            RunnerJNILib.DsMapAddString(dsMapIndex, "error", error.toString());
            RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }

            @Override
            public void onAdClicked(Placement placement, AdInfo adInfo)
            {
            int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
            RunnerJNILib.DsMapAddString(dsMapIndex, "type", "ironsource_rewarded_video_clicked");
            RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
            }
        });

        IronSource.init(activity, IS_appKey, IronSource.AD_UNIT.REWARDED_VIDEO);
    }

and same in ios: new .h file:


#import "IronSource/IronSource.h"

//#import <IronSource/ISConfigurations.h>
#import <AdSupport/AdSupport.h>

@interface listener_interstitial : NSObject<LevelPlayInterstitialDelegate>
@end

@interface listener_reward_manual :NSObject<LevelPlayRewardedVideoManualDelegate>
@end

@interface listener_reward :NSObject<LevelPlayRewardedVideoManualDelegate>
@end

@interface IronSourceGM:NSObject <ISOfferwallDelegate,LevelPlayBannerDelegate,ISImpressionDataDelegate>
{
    double bottom;
}

@property (nonatomic, strong) ISBannerView *bannerView;
@property (nonatomic, strong) NSString *IS_AppKey;
@property (nonatomic, strong) listener_interstitial *m_listener_interstitial;
@property (nonatomic, strong) listener_reward *m_listener_reward;
@property (nonatomic, strong) listener_reward_manual *m_listener_reward_manual;
@end

listener_reward:

/**
 Called after a rewarded video has changed its availability to true.
 @param adInfo The info of the ad.
 Replaces the delegate rewardedVideoHasChangedAvailability:(true)available 
 */
- (void)hasAdAvailableWithAdInfo:(ISAdInfo *)adInfo{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_availability_changed");
    dsMapAddDouble(dsMapIndex,(char*)"available", 1.0);
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has changed its availability to false.
 Replaces the delegate rewardedVideoHasChangedAvailability:(false)available 
 */
- (void)hasNoAvailableAd{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_availability_changed");
    dsMapAddDouble(dsMapIndex,(char*)"available", 0.0);
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has been viewed completely and the user is eligible for a reward.
 @param placementInfo An object that contains the placement's reward name and amount.
 @param adInfo The info of the ad.
 */
- (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo withAdInfo:(ISAdInfo *)adInfo {
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_rewarded");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has attempted to show but failed.
 @param error The reason for the error
 @param adInfo The info of the ad.
 */
- (void)didFailToShowWithError:(NSError *)error andAdInfo:(ISAdInfo *)adInfo {
    AudioResumeAll();
    Audio_DeviceResume();

    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_show_failed");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has been opened.
 @param adInfo The info of the ad.
 */
- (void)didOpenWithAdInfo:(ISAdInfo *)adInfo {
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_opened");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has been dismissed.
 @param adInfo The info of the ad.
 */
- (void)didCloseWithAdInfo:(ISAdInfo *)adInfo {
    AudioResumeAll();
    Audio_DeviceResume();

    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_closed");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
/**
 Called after a rewarded video has been clicked. 
 This callback is not supported by all networks, and we recommend using it 
 only if it's supported by all networks you included in your build
 @param adInfo The info of the ad.
 */
- (void)didClick:(ISPlacementInfo *)placementInfo withAdInfo:(ISAdInfo *)adInfo {
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_clicked");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}
@end

listener_reward_manual:

@implementation listener_reward_manual

- (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo withAdInfo:(ISAdInfo *)adInfo
{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_rewarded");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didFailToShowWithError:(NSError *)error andAdInfo:(ISAdInfo *)adInfo
{
    AudioResumeAll();
    Audio_DeviceResume();

    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_show_failed");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didOpenWithAdInfo:(ISAdInfo *)adInfo
{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_opened");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didClick:(ISPlacementInfo *)placementInfo withAdInfo:(ISAdInfo *)adInfo
{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_clicked");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didCloseWithAdInfo:(ISAdInfo *)adInfo
{
    AudioResumeAll();
    Audio_DeviceResume();

    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_closed");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didLoadWithAdInfo:(ISAdInfo *)adInfo
{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_ready");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

- (void)didFailToLoadWithError:(NSError *)error
{
    int dsMapIndex = dsMapCreate();
    dsMapAddString(dsMapIndex, (char*)"type",(char*)"ironsource_rewarded_video_load_failed");
    createSocialAsyncEventWithDSMap(dsMapIndex);
}

@end

inits:

-(void) ironsource_rewarded_video_init
{
    self.m_listener_reward = [listener_reward new];
    [IronSource setLevelPlayRewardedVideoDelegate: self.m_listener_reward];
    [IronSource initWithAppKey:self.IS_AppKey adUnits:@[IS_REWARDED_VIDEO]];
}

-(void) ironsource_rewarded_video_manual_init
{
    self.m_listener_reward_manual = [listener_reward_manual new];
    [IronSource setLevelPlayRewardedVideoManualDelegate: self.m_listener_reward_manual];
    [IronSource initWithAppKey:self.IS_AppKey adUnits:@[IS_REWARDED_VIDEO]];
}
jzavala-YYG commented 1 month ago

Hi @romhaviv!

Right, are a bit different, but if I'm correct it's the same feature. not sure if add again the same feature under other work flow it's the best for most of the users, can be confusing.

But if it exists a really positive advantage against the manual flow let us know, (more than avoid call load())

romhaviv commented 12 hours ago

@jzavala-YYG @stuckie hi, sorry for the late reply,

  1. its needed for backward compatibility,
  2. most of the users wouldn't want to manage loading themselves, its extra code and headaches that can easily be avoided by letting ironsource's sdk do it for them.
  3. the official ironsource sdk supports both, why hide one of the functionallities?
  4. the code is already written and tested in production by our app, so its really not much work to add it :)