ios - Video Ads from Vungle in Sprite kit Scene -



ios - Video Ads from Vungle in Sprite kit Scene -

i trying add together vungle video ads in sprite kit skscene. have sprite node when clicked, should load ad. guide provided vungle https://github.com/vungle/vungle-resources/blob/master/ios-resources/ios-dev-guide.md shows how place advertisement through view controller.

vunglesdk* sdk = [vunglesdk sharedsdk]; [sdk playad:self];

i have different skscene , want play advertisement in scene rather view controller. how can accomplish it.

following skscene code user clicking skspritenode , want advertisement load.

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { (uitouch *touch in touches) { sknode *n = [self nodeatpoint:[touch locationinnode:self]]; if ( [n.name isequal: @"play"]) { [self levelselect]; } else if( [n.name isequal: @"coins"]){ vunglesdk* sdk = [vunglesdk sharedsdk]; [sdk playad:self.view]; //todo } }

this gives error not passing view controller method playad. can guide me?

sovled if else gets same problem, here solution:-

in view controller , within viewdidload method

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(handlenotification:) name:@"playvungle" object:nil];

also create method

-(void)playvunglead{ vunglesdk* sdk = [vunglesdk sharedsdk]; [sdk playad:self]; }

don't forget import vunglesdk/vunglesdk.h in skscene, within touches began method this

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { (uitouch *touch in touches) { sknode *n = [self nodeatpoint:[touch locationinnode:self]]; if ( [n.name isequal: @"play"]) { [self levelselect]; } else if( [n.name isequal: @"coins"]){ [[nsnotificationcenter defaultcenter] postnotificationname:@"playvungle" object:nil]; //sends message viewcontroller show ad. } }

here sending message view controller play vungle ad. when touch "coins" skspritenode in scene, should play video ad.

ios sprite-kit vungle-ads

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -