requestSubscription() (Deprecated)
⚠️ Deprecated:
requestSubscription()
remains for backwards compatibility with the v5 API. New code should callrequestPurchase()
with eitherPurchaseType.subs
(legacy API) or the unifiedRequestPurchaseProps
flow.
Overview
requestSubscription()
starts the platform subscription purchase flow using the legacy method signature that predates the OpenIAP migration. The method still works but is implemented as a thin wrapper around requestPurchase()
.
Use this API only while migrating older code. All new implementations should move to requestPurchase()
so you can take advantage of the typed request builder and platform-specific props.
Signature
Future<dynamic> requestSubscription(
String productId, {
int? prorationModeAndroid,
String? obfuscatedAccountIdAndroid,
String? obfuscatedProfileIdAndroid,
String? purchaseTokenAndroid,
int? offerTokenIndex,
})
Parameters
productId
– Subscription identifier to purchaseprorationModeAndroid
(Android only) – BillingClient proration mode for upgrades/downgradesobfuscatedAccountIdAndroid
(Android only) – Stable per-account identifier for Play BillingobfuscatedProfileIdAndroid
(Android only) – Stable per-profile identifier for Play BillingpurchaseTokenAndroid
(Android only, deprecated) – Legacy upgrade token (use the newpurchaseToken
field viarequestPurchase()
instead)offerTokenIndex
(Android only) – Index of the subscription offer to purchase
Migration Guide
Old code (legacy):
await FlutterInappPurchase.instance.requestSubscription('com.example.monthly');
Recommended replacement:
await FlutterInappPurchase.instance.requestPurchase(
request: RequestPurchase(
ios: RequestPurchaseIOS(sku: 'com.example.monthly'),
android: RequestPurchaseAndroid(skus: ['com.example.monthly']),
),
type: PurchaseType.subs,
);
Or, when using the new OpenIAP helpers:
await FlutterInappPurchase.instance.requestPurchaseWithBuilder(
build: (builder) {
builder
..type = ProductQueryType.Subs
..ios.sku = 'com.example.monthly'
..android.skus = ['com.example.monthly'];
},
);
Notes
- The method simply forwards to
requestPurchase()
; no new features will be added here. purchaseTokenAndroid
is maintained for binary compatibility but should be replaced with the newpurchaseToken
property when usingRequestPurchaseProps
.- This method will be removed in a future major release (7.0). Plan your migration accordingly.