-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[in_app_purchase_storekit] Add show manage subscriptions path #12454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,7 @@ class _MyAppState extends State<_MyApp> { | |
| _buildProductList(), | ||
| _buildConsumableBox(), | ||
| _buildCodeRedemptionButton(), | ||
| _buildShowManageSubscriptionsButton(), | ||
| _buildRestoreButton(), | ||
| ], | ||
| ), | ||
|
|
@@ -419,6 +420,29 @@ class _MyAppState extends State<_MyApp> { | |
| ); | ||
| } | ||
|
|
||
| Widget _buildShowManageSubscriptionsButton() { | ||
| if (_loading) { | ||
| return Container(); | ||
| } | ||
|
|
||
| return Padding( | ||
| padding: const EdgeInsets.all(4.0), | ||
| child: Row( | ||
| mainAxisAlignment: MainAxisAlignment.end, | ||
| children: <Widget>[ | ||
| TextButton( | ||
| style: TextButton.styleFrom( | ||
| backgroundColor: Theme.of(context).colorScheme.primary, | ||
| foregroundColor: Colors.white, | ||
| ), | ||
| onPressed: () => _iapStoreKitPlatformAddition.showManageSubscriptions(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The onPressed: () async {
try {
await _iapStoreKitPlatformAddition.showManageSubscriptions();
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error: $e')),
);
}
}
},
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is ok for the internal example |
||
| child: const Text('Manage subscriptions'), | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Widget _buildRestoreButton() { | ||
| if (_loading) { | ||
| return Container(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing UIKit properties such as
viewController,view,window, andwindowScenemust be done on the main thread (@MainActor). Currently, the guard statement retrieves thewindowScenebefore entering the@MainActortask block, which can lead to thread-safety issues or crashes if this method is invoked from a background thread. Moving the entire guard statement inside the@MainActortask ensures safe UI-related operations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is more correct but I was reflecting the pattern in
presentOfferCodeRedeemSheet. Happy to update this one or both