Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ironsource_rewarded_video_init (NOT MANUAL) is missing #13

Open
romhaviv opened this issue Jul 27, 2024 · 2 comments
Open

ironsource_rewarded_video_init (NOT MANUAL) is missing #13

romhaviv opened this issue Jul 27, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request extension-bug Something isn't working

Comments

@romhaviv
Copy link

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
Copy link
Contributor

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())

@stuckie stuckie added the enhancement New feature or request label Jul 29, 2024
@stuckie stuckie moved this from Triage to Backlog in Team Workload Jul 29, 2024
@romhaviv
Copy link
Author

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request extension-bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

4 participants