platform_api.dart
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:pigeon/pigeon.dart';
class AppleSignInModel {
final String userId;
final String? email;
final String? nickname;
final String? identityToken;
AppleSignInModel({
required this.userId,
this.email,
this.nickname,
this.identityToken,
});
}
class AppleProductInfo {
final String productId;
final String originPriceDescription;
final String? priceDescription;
final double originPrice;
final double? price;
final bool isTrialPeriod;
AppleProductInfo({
required this.productId,
required this.originPriceDescription,
this.priceDescription,
required this.originPrice,
this.price,
required this.isTrialPeriod,
});
}
enum AppleProductPaymentErrorMsg {
missingUUID,
productNotFound,
userCancelled,
failedVerification,
unknown,
}
class AppleProductPaymentResult {
final String productId;
final String? appAccountToken;
final String? originalTransactionId;
final String? transactionId;
final bool? success;
/// 错误描述:
/// 和AppleProductPaymentErrorMsg匹配的flutter处理,
/// 不匹配的则是StoreKit 直接给的错误描述,直接展示即可
final String? errorMessage;
AppleProductPaymentResult({
required this.productId,
this.appAccountToken,
this.originalTransactionId,
this.transactionId,
this.success,
this.errorMessage,
});
}
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/pigeon/platform_api.g.dart',
dartPackageName: 'doublefeel_flutter',
dartOptions: DartOptions(),
kotlinOut:
'android/app/src/main/kotlin/com/doublefeel/app/pigeon/PlatformApi.kt',
kotlinOptions: KotlinOptions(
package: 'com.doublefeel.app.pigeon.platform',
),
swiftOut: 'ios/Runner/Pigeon/PlatformApi.swift',
swiftOptions: SwiftOptions(),
arkTSOut: 'ohos/entry/src/main/ets/pigeon/PlatformApi.ets',
copyrightHeader: 'pigeon/copyright.txt',
),
)
@HostApi()
abstract class PlatformHostApi {
/// 返回完整的 User-Agent 字符串,由 native 侧组装:
/// `{systemWebViewUA} {appName}/{versionCode}({versionName})({manufacturer}##{brand}##{model}; {OS}{osVersion}; {height}x{width})(huawei)`
String getFullUserAgent();
/// 请求苹果登录
@async
AppleSignInModel? requestAppleSignIn();
/// 查询指定id的苹果商品
@async
AppleProductInfo? requestAppleProductInfo(String productId);
/// 从服务器下单后请求苹果支付
@async
AppleProductPaymentResult? performApplePayment(String productId, String uuid);
}