fix(iap): eagerly start IAP service at launch (final review I-1)
iapServiceProvider was lazy and only read by Settings, so the purchase stream attached only after opening Settings — deferred/interrupted/restored transactions wouldn't be delivered or completed until then. Read it in the post-frame callback so the stream is live for the whole session.
This commit is contained in:
@@ -19,6 +19,10 @@ class _BlockSeasonsAppState extends ConsumerState<BlockSeasonsApp> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
ref.read(consentServiceProvider).ensureConsentAndInitialize();
|
ref.read(consentServiceProvider).ensureConsentAndInitialize();
|
||||||
|
// Eagerly start the IAP service so its purchase stream is live for the
|
||||||
|
// whole session — restores and interrupted/deferred transactions are
|
||||||
|
// delivered (and completed) even if the player never opens Settings.
|
||||||
|
ref.read(iapServiceProvider);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user