How can I setup cordova-plugin-purchase v13 with Angular 15?
This is what I have tried. Here is my PaymentService which is provided in root.
// payment.service.ts
import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
import 'cordova-plugin-purchase';
@Injectable({
providedIn: 'root'
})
export class PaymentService {
constructor(
private readonly store: CdvPurchase.Store,
private readonly platform: Platform,
) {
this.platform.ready().then((readySource) => {
this.store.initialize();
});
}
}
I'm providing the Store class in AppModule
// app.module.ts
import 'cordova-plugin-purchase';
@NgModule({
// Omitting unrelevant parts
providers: [
{
provide: CdvPurchase.Store,
useFactory: () => { return window.CdvPurchase.Store }
}
]
})
export class AppModule { }
Firstly I'm getting this error in app.module.ts
Uncaught ReferenceError: CdvPurchase is not defined
And down the line I'm getting this dependency injection error
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(PaymentModule)[PaymentService -> PaymentService -> Store -> Store -> Store]:
NullInjectorError: No provider for Store!
NullInjectorError: R3InjectorError(PaymentModule)[PaymentService -> PaymentService -> Store -> Store -> Store]:
Thanks for the help.
@Component({ selector: 'app-questions', templateUrl: './napp2.page.html' , providers: [{provide: CdvPurchase.Store}]
})
its work for me