Is there a way to configure cordova-plugin-purchase v13 in conjunction with Angular 15?
Here is a snippet of what I have attempted. Below is my PaymentService class that is set to be provided at the root level.
// 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 have included the Store class in the AppModule
// app.module.ts
import 'cordova-plugin-purchase';
@NgModule({
// Irrelevant parts omitted
providers: [
{
provide: CdvPurchase.Store,
useFactory: () => { return window.CdvPurchase.Store }
}
]
})
export class AppModule { }
Initially, I encounter an error in app.module.ts
Uncaught ReferenceError: CdvPurchase is not defined
Later on, I face a dependency injection error as mentioned below
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]:
Any help would be greatly appreciated.