文档
This commit is contained in:
@@ -31,6 +31,8 @@ import {
|
||||
FreechargePersonalBind,
|
||||
proxyBackgroundService,
|
||||
type RebindConfig,
|
||||
type PatchConfig,
|
||||
type FcmNotificationTapPayload,
|
||||
PhonePePersonalBindResult,
|
||||
PaytmPersonalBindResult,
|
||||
MobikwikPersonalBind,
|
||||
@@ -57,6 +59,14 @@ import Api, {
|
||||
getServerDomain,
|
||||
} from '../services/api';
|
||||
|
||||
/** ipay patch 期望,bind 与 ProxyService FCM 重绑共用 */
|
||||
const PATCH_EXPECT: PatchConfig = {
|
||||
chType: 'ipay',
|
||||
paytmChVersion: '3',
|
||||
phonepeChVersion: '1',
|
||||
mobikwikChVersion: '1',
|
||||
};
|
||||
|
||||
function formatWalletTypeLabel(walletType: string) {
|
||||
return walletType.replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
@@ -77,6 +87,16 @@ function groupBoundWallets(wallets: WalletItem[]) {
|
||||
}));
|
||||
}
|
||||
|
||||
function getBindKeyForWalletType(walletType: string): string | null {
|
||||
switch (walletType) {
|
||||
case 'paytm': return 'paytm_personal_token';
|
||||
case 'phonepe': return 'phonepe_personal_token';
|
||||
case 'mobikwik': return 'mobikwik_personal_token';
|
||||
case 'freecharge': return 'freecharge_personal_token';
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getBindKeyForWallet(item: WalletItem): string | null {
|
||||
const otp = item.otpMode === true;
|
||||
switch (item.walletType) {
|
||||
@@ -212,8 +232,10 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
};
|
||||
|
||||
async componentDidMount() {
|
||||
proxyBackgroundService.setNotificationTapHandler(this.handleNotificationTap);
|
||||
await loadServerDomain();
|
||||
await this.loadAdid();
|
||||
await proxyBackgroundService.syncPatchConfig(PATCH_EXPECT);
|
||||
|
||||
const doLogin = () => {
|
||||
Api.instance.login('test123', '123456').then(async () => {
|
||||
@@ -229,12 +251,32 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
proxyBackgroundService.setNotificationTapHandler(null);
|
||||
this.stopProxyClient();
|
||||
this.appStateSubscription?.remove();
|
||||
}
|
||||
|
||||
handleNotificationTap = (payload: FcmNotificationTapPayload) => {
|
||||
if (payload.cmd !== 'rebind_wallet') return;
|
||||
const { walletId, walletType, phone } = payload.params;
|
||||
const item = walletId
|
||||
? this.state.wallets.find(w => w.id === walletId)
|
||||
: undefined;
|
||||
if (item) {
|
||||
this.handleRebind(item);
|
||||
return;
|
||||
}
|
||||
if (walletType) {
|
||||
const key = getBindKeyForWalletType(walletType);
|
||||
if (key) this.openWalletBind(key, phone);
|
||||
}
|
||||
};
|
||||
|
||||
handleAppStateChange = (nextAppState: AppStateStatus) => {
|
||||
if (nextAppState === 'active') this.fetchWallets();
|
||||
if (nextAppState === 'active') {
|
||||
this.fetchWallets();
|
||||
void proxyBackgroundService.syncPendingNotificationTap();
|
||||
}
|
||||
};
|
||||
|
||||
buildRebindConfig = (): RebindConfig => ({
|
||||
@@ -249,6 +291,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
this.clientId = DeviceInfo.getUniqueIdSync();
|
||||
const userId = Api.instance.getUserId();
|
||||
this.setState({ proxyStatus: 'connecting' });
|
||||
await proxyBackgroundService.syncPatchConfig(PATCH_EXPECT);
|
||||
await proxyBackgroundService.syncRebindConfig(this.buildRebindConfig());
|
||||
await proxyBackgroundService.start({
|
||||
wsUrl: Api.WS_URL,
|
||||
@@ -394,7 +437,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
this.setState({ [key]: false, bindPrefillMobile: '' } as any);
|
||||
|
||||
if (showPaytmPersonalBind && paytmPersonalBindType === 'tokenMode') {
|
||||
const remoteVersion = '2';
|
||||
const { chType, paytmChVersion: remoteVersion } = PATCH_EXPECT;
|
||||
return (
|
||||
<Modal
|
||||
visible
|
||||
@@ -405,7 +448,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
processString="Processing..."
|
||||
isDebug
|
||||
onSuccess={(result: PaytmPersonalBindResult) => {
|
||||
if (result.chType != 'ipay') {
|
||||
if (result.chType != chType) {
|
||||
Alert.alert('Bind Failed', 'Patched Paytm app not installed. Reinstall required');
|
||||
return;
|
||||
}
|
||||
@@ -476,7 +519,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
);
|
||||
}
|
||||
if (showPhonePePersonalBind && phonePePersonalBindType === 'tokenMode') {
|
||||
const remoteVersion = '1';
|
||||
const { chType, phonepeChVersion: remoteVersion } = PATCH_EXPECT;
|
||||
return (
|
||||
<Modal
|
||||
visible
|
||||
@@ -488,7 +531,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
||||
userToken={Api.instance.getUserToken()}
|
||||
isDebug
|
||||
onSuccess={(result: PhonePePersonalBindResult) => {
|
||||
if (result.chType != 'ipay') {
|
||||
if (result.chType != chType) {
|
||||
Alert.alert('Bind Failed', 'Patched PhonePe app not installed. Reinstall required');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user