Hi guys,
I have this:
pets.ts PetsPage
import { AdMobPro } from '@ionic-native/admob-pro';
@Component({
selector: 'page-pets',
templateUrl: 'pets.html'
})
export class PetsPage {
constructor(
private navCtrol: NavController,
private admob: AdMobPro,
private app: App,
) { }
ionViewDidLoad() {
this.admob.onAdPresent()
.subscribe((data) => {
if (data.adType == 'rewardvideo') {
alert('aqui');
}
});
};
addPet() {
this.navCtrol.push('PetPage');
}
PetPage Pet.ts
import { AdMobPro } from '@ionic-native/admob-pro';
@Component({
selector: 'page-pet',
templateUrl: 'pet.html'
})
export class PetPage implements OnInit {
private todo: FormGroup;
submitAttempt: boolean = false;
isPet: boolean = true; //variable q se usa cuando insertamos imagenes
pet = {} as Pet;
listOfValuesType: ListOfValues[] = [];
//listOfValuesRaza: ListOfValues[] = [];
constructor(
private admob: AdMobPro) { }
ionViewDidLoad() {
this.admob.onAdPresent()
.subscribe((data) => {
//rewardType
if (data.adType == 'rewardvideo') {
}
});
}
sharedPet() {
this.admob.prepareRewardVideoAd({
adId: 'ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxx',
autoShow: true
});
}
WIch one have ur module with your providers
import { AdMobPro } from '@ionic-native/admob-pro';
@NgModule({
declarations: [PetsPage],
providers: [AdMobPro ],
imports: [
IonicPageModule.forChild(PetsPage)
]
})
export class PetsPageModule{}
import { AdMobPro } from '@ionic-native/admob-pro';
@NgModule({
declarations: [PetPage],
providers:[IAdMobPro],
imports: [
IonicPageModule.forChild(PetPage)
]
})
export class PetPageModule{}
1 - I will go to call the function addPet
2 - Call the function sharedPet
My problem is that I don’t know why the event onAdPresent run in the two components when I invoke the function sharedPet in the second component (PetPage). The function sharedPet have an actionthat active the event onAdPresent,
but I do not understand why the event is invoked in the PetsPage component, because PetsPage and PetPage have differents modules and provider.
Any idea?
Thanks