platform_api.dart
3.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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 WatchAppOtherInfo {
final int? userId;
final String? nickname;
final String? markName;
WatchAppOtherInfo({
this.userId,
this.nickname,
this.markName,
});
}
class AppleProductInfo {
/// 苹果商品id
final String productId;
/// 原价描述
final String originPriceDescription;
/// 真实价格描述
final String priceDescription;
/// 原价格
final double originPrice;
/// 真实价格, = 0 代表试用商品
final double price;
/// price/unit = 单位价格
final String unitPrice;
/// 当前货币符号
final String currencyCode;
/// 当前用户是否可以试用
final bool isTrialPeriod;
AppleProductInfo({
required this.productId,
required this.originPriceDescription,
required this.priceDescription,
required this.originPrice,
required this.price,
required this.unitPrice,
required this.currencyCode,
required this.isTrialPeriod,
});
}
class AppleProductPaymentResult {
final String productId;
final String? appAccountToken;
final String? originalTransactionId;
final String? transactionId;
/// success 为空时是支付pending状态,不需要处理
/// 只有 true/false时才是支付结果出来的时候
final bool? success;
/// 错误描述, success = false时取用:
/// 优先取 errorCode: -1: UUID格式错误, -2: productID查询商品失败,-3:用户取消支付, -4:支付校验失败,-5:未知错误(Apple未知错误)
/// errorCode 为空时,取用 errorMessage
final String? errorMessage;
final int? errorCode;
AppleProductPaymentResult({
required this.productId,
this.appAccountToken,
this.originalTransactionId,
this.transactionId,
this.success,
this.errorMessage,
this.errorCode,
});
}
@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();
/// 更新用户信息, 有登录态后调用
/// jsonString: UserPreferences的序列化string
/// baseUrl: 请求地址, https://api.doublefeel.cn
void updateLoginInfo(String jsonString, String baseUrl);
/// 设置好友显示到表盘
void updateWatchOtherUserInfo(WatchAppOtherInfo? otherInfo);
/// 刷新表盘
void refreshWatchSurface();
/// 请求苹果登录
@async
AppleSignInModel? requestAppleSignIn();
/// 查询指定id的苹果商品
/// productId: 苹果商品id
/// baseUnit: 除数基础单位(多少个天、周、月) ->
@async
AppleProductInfo? requestAppleProductInfo(String productId, int baseUnit);
/// 从服务器下单后请求苹果支付
@async
AppleProductPaymentResult? performApplePayment(String productId, String uuid);
/// 恢复购买
@async
bool performRestore();
}