Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit dfb1fcfe
authored
2026-07-01 14:38:31 +0800
by
ethanlamzs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
testing ios pay
1 parent
a53ff2fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
20 deletions
ios/Runner/LocalIAP.storekit
lib/services/subscription_service_ios.dart
lib/ui/pages/subscription_page.dart
macos/Flutter/GeneratedPluginRegistrant.swift
ios/Runner/LocalIAP.storekit
View file @
dfb1fcf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
"identifier" : "8ADF1697",
"identifier" : "8ADF1697",
"nonRenewingSubscriptions" : [
"nonRenewingSubscriptions" : [
{
{
"displayPrice" : "
59
.0",
"displayPrice" : "
8
.0",
"familyShareable" : false,
"familyShareable" : false,
"internalID" : "9F78CD7A",
"internalID" : "9F78CD7A",
"localizations" : [
"localizations" : [
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
"type" : "NonRenewingSubscription"
"type" : "NonRenewingSubscription"
},
},
{
{
"displayPrice" : "1
2
0",
"displayPrice" : "1
6.
0",
"familyShareable" : false,
"familyShareable" : false,
"internalID" : "119703EA",
"internalID" : "119703EA",
"localizations" : [
"localizations" : [
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
"type" : "NonRenewingSubscription"
"type" : "NonRenewingSubscription"
},
},
{
{
"displayPrice" : "
18
0",
"displayPrice" : "
22.
0",
"familyShareable" : false,
"familyShareable" : false,
"internalID" : "4768E67B",
"internalID" : "4768E67B",
"localizations" : [
"localizations" : [
...
...
lib/services/subscription_service_ios.dart
View file @
dfb1fcf
...
@@ -10,8 +10,8 @@ class SubscriptionService {
...
@@ -10,8 +10,8 @@ class SubscriptionService {
// App Store Connect 中配置的订阅产品 ID(组内唯一)
// App Store Connect 中配置的订阅产品 ID(组内唯一)
// 例如月度、年度两种方案
// 例如月度、年度两种方案
static
const
String
monthlySubId_1
=
'cn.banxe.appframe.membership.1m'
;
static
const
String
monthlySubId_1
=
'cn.banxe.appframe.membership.1m'
;
//
static const String monthlySubId_2 = 'cn.banxe.appframe.membership.2m';
static
const
String
monthlySubId_2
=
'cn.banxe.appframe.membership.2m'
;
//
static const String monthlySubId_3 = 'cn.banxe.appframe.membership.3m';
static
const
String
monthlySubId_3
=
'cn.banxe.appframe.membership.3m'
;
final
InAppPurchase
_iap
=
InAppPurchase
.
instance
;
final
InAppPurchase
_iap
=
InAppPurchase
.
instance
;
late
StreamSubscription
<
List
<
PurchaseDetails
>>
_purchaseUpdatedSubscription
;
late
StreamSubscription
<
List
<
PurchaseDetails
>>
_purchaseUpdatedSubscription
;
...
@@ -45,7 +45,9 @@ class SubscriptionService {
...
@@ -45,7 +45,9 @@ class SubscriptionService {
// ---------- 获取产品信息 ----------
// ---------- 获取产品信息 ----------
Future
<
void
>
_fetchProducts
()
async
{
Future
<
void
>
_fetchProducts
()
async
{
const
Set
<
String
>
ids
=
{
monthlySubId_1
};
const
Set
<
String
>
ids
=
{
monthlySubId_1
,
monthlySubId_2
,
monthlySubId_3
};
final
ProductDetailsResponse
response
=
await
_iap
.
queryProductDetails
(
ids
);
final
ProductDetailsResponse
response
=
await
_iap
.
queryProductDetails
(
ids
);
if
(
response
.
notFoundIDs
.
isNotEmpty
)
{
if
(
response
.
notFoundIDs
.
isNotEmpty
)
{
...
@@ -56,8 +58,9 @@ class SubscriptionService {
...
@@ -56,8 +58,9 @@ class SubscriptionService {
_products
=
response
.
productDetails
;
_products
=
response
.
productDetails
;
debugPrint
(
'获取到
${_products.length}
个产品'
);
debugPrint
(
'获取到
${_products.length}
个产品'
);
for
(
var
p
in
_products
)
{
for
(
var
p
in
_products
)
{
debugPrint
(
'产品ID:
${p.id}
, 标题:
${p.title}
, 价格:
${p.price}
'
);
debugPrint
(
'
x1=====>
产品ID:
${p.id}
, 标题:
${p.title}
, 价格:
${p.price}
'
);
}
}
}
}
// ---------- 购买订阅 ----------
// ---------- 购买订阅 ----------
...
...
lib/ui/pages/subscription_page.dart
View file @
dfb1fcf
...
@@ -12,7 +12,9 @@ class SubscriptionPage extends StatefulWidget {
...
@@ -12,7 +12,9 @@ class SubscriptionPage extends StatefulWidget {
}
}
class
_SubscriptionPageState
extends
State
<
SubscriptionPage
>
{
class
_SubscriptionPageState
extends
State
<
SubscriptionPage
>
{
final
SubscriptionService
_subService
=
SubscriptionService
();
final
SubscriptionService
_subService
=
SubscriptionService
();
bool
_isInitialized
=
false
;
bool
_isInitialized
=
false
;
@override
@override
...
@@ -32,32 +34,54 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
...
@@ -32,32 +34,54 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
await
_subService
.
buySubscription
(
product
);
await
_subService
.
buySubscription
(
product
);
}
catch
(
e
)
{
}
catch
(
e
)
{
// 显示出错信息
// 显示出错信息
debugPrint
(
e
.
toString
());
}
}
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
if
(!
_isInitialized
)
return
CircularProgressIndicator
();
if
(!
_isInitialized
)
return
CircularProgressIndicator
();
return
ListView
.
builder
(
// return ListView.builder(
itemCount:
_subService
.
products
.
length
,
// itemCount: _subService.products.length,
itemBuilder:
(
context
,
index
)
{
// itemBuilder: (context, index) {
final
product
=
_subService
.
products
[
index
];
// final product = _subService.products[index];
return
ListTile
(
// return ListTile(
title:
Text
(
product
.
title
),
// title: Text(product.title),
subtitle:
Text
(
product
.
description
),
// subtitle: Text(product.id),
trailing:
ElevatedButton
(
// trailing: ElevatedButton(
onPressed:
()
=>
_buy
(
product
),
// onPressed: () => _buy(product),
child:
Text
(
product
.
price
),
// child: Text(product.price),
// ),
// );
// },
// );
return
Scaffold
(
body:
Center
(
child:
ListView
.
builder
(
itemCount:
_subService
.
products
.
length
,
itemBuilder:
(
context
,
index
)
{
final
product
=
_subService
.
products
[
index
];
return
ListTile
(
title:
Text
(
product
.
title
),
subtitle:
Text
(
product
.
description
),
trailing:
ElevatedButton
(
onPressed:
()
=>
_buy
(
product
),
child:
Text
(
product
.
price
),
),
);
},
),
),
);
),
},
);
);
}
}
@override
@override
void
dispose
()
{
void
dispose
()
{
_subService
.
dispose
();
//
_subService.dispose();
super
.
dispose
();
super
.
dispose
();
}
}
}
}
\ No newline at end of file
\ No newline at end of file
macos/Flutter/GeneratedPluginRegistrant.swift
View file @
dfb1fcf
...
@@ -15,6 +15,7 @@ import flutter_image_compress_macos
...
@@ -15,6 +15,7 @@ import flutter_image_compress_macos
import
flutter_localization
import
flutter_localization
import
flutter_sound
import
flutter_sound
import
geolocator_apple
import
geolocator_apple
import
in_app_purchase_storekit
import
mobile_scanner
import
mobile_scanner
import
network_info_plus
import
network_info_plus
import
open_file_mac
import
open_file_mac
...
@@ -23,10 +24,12 @@ import path_provider_foundation
...
@@ -23,10 +24,12 @@ import path_provider_foundation
import
photo_manager
import
photo_manager
import
shared_preferences_foundation
import
shared_preferences_foundation
import
sign_in_with_apple
import
sign_in_with_apple
import
sqflite_darwin
import
tencent_cloud_chat_sdk
import
tencent_cloud_chat_sdk
import
url_launcher_macos
import
url_launcher_macos
import
video_player_avfoundation
import
video_player_avfoundation
import
volume_controller
import
volume_controller
import
wakelock_plus
import
webview_flutter_wkwebview
import
webview_flutter_wkwebview
func
RegisterGeneratedPlugins
(
registry
:
FlutterPluginRegistry
)
{
func
RegisterGeneratedPlugins
(
registry
:
FlutterPluginRegistry
)
{
...
@@ -40,6 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
...
@@ -40,6 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterLocalizationPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FlutterLocalizationPlugin"
))
FlutterLocalizationPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FlutterLocalizationPlugin"
))
FlutterSoundPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FlutterSoundPlugin"
))
FlutterSoundPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FlutterSoundPlugin"
))
GeolocatorPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"GeolocatorPlugin"
))
GeolocatorPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"GeolocatorPlugin"
))
InAppPurchasePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"InAppPurchasePlugin"
))
MobileScannerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"MobileScannerPlugin"
))
MobileScannerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"MobileScannerPlugin"
))
NetworkInfoPlusPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"NetworkInfoPlusPlugin"
))
NetworkInfoPlusPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"NetworkInfoPlusPlugin"
))
OpenFilePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"OpenFilePlugin"
))
OpenFilePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"OpenFilePlugin"
))
...
@@ -48,9 +52,11 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
...
@@ -48,9 +52,11 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PhotoManagerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"PhotoManagerPlugin"
))
PhotoManagerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"PhotoManagerPlugin"
))
SharedPreferencesPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SharedPreferencesPlugin"
))
SharedPreferencesPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SharedPreferencesPlugin"
))
SignInWithApplePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SignInWithApplePlugin"
))
SignInWithApplePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SignInWithApplePlugin"
))
SqflitePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SqflitePlugin"
))
TencentCloudChatSdkPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"TencentCloudChatSdkPlugin"
))
TencentCloudChatSdkPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"TencentCloudChatSdkPlugin"
))
UrlLauncherPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"UrlLauncherPlugin"
))
UrlLauncherPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"UrlLauncherPlugin"
))
FVPVideoPlayerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FVPVideoPlayerPlugin"
))
FVPVideoPlayerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"FVPVideoPlayerPlugin"
))
VolumeControllerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"VolumeControllerPlugin"
))
VolumeControllerPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"VolumeControllerPlugin"
))
WakelockPlusMacosPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"WakelockPlusMacosPlugin"
))
WebViewFlutterPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"WebViewFlutterPlugin"
))
WebViewFlutterPlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"WebViewFlutterPlugin"
))
}
}
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment