新后台

This commit is contained in:
2026-06-07 13:43:53 +08:00
parent a736e52943
commit 143b8f3b24
14 changed files with 324 additions and 28 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ ios/Pods
android/app/release android/app/release
__pycache__ __pycache__
others others
*.lock

View File

@@ -115,6 +115,7 @@ android {
dependencies { dependencies {
// The version of react-native is set by the React Native Gradle Plugin // The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android") implementation("com.facebook.react:react-android")
implementation("com.google.android.gms:play-services-ads-identifier:18.1.0")
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {

View File

@@ -1,9 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application <application
android:name=".MainApplication" android:name=".MainApplication"
@@ -32,5 +36,9 @@
<data android:scheme="ipay" android:host="native" /> <data android:scheme="ipay" android:host="native" />
</intent-filter> </intent-filter>
</activity> </activity>
<service
android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"
android:foregroundServiceType="dataSync"
tools:node="merge" />
</application> </application>
</manifest> </manifest>

View File

@@ -0,0 +1,37 @@
package com.rnpay;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
public class AdIdModule extends ReactContextBaseJavaModule {
public AdIdModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "AdId";
}
@ReactMethod
public void getAdvertisingId(Promise promise) {
ReactApplicationContext ctx = getReactApplicationContext();
new Thread(() -> {
try {
AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(ctx);
if (info.isLimitAdTrackingEnabled()) {
promise.reject("LIMITED", "Ad tracking limited");
return;
}
String id = info.getId();
promise.resolve(id != null ? id : "");
} catch (Exception e) {
promise.reject("ERROR", e.getMessage(), e);
}
}).start();
}
}

View File

@@ -0,0 +1,21 @@
package com.rnpay;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class AdIdPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.asList(new AdIdModule(reactContext));
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}

View File

@@ -23,6 +23,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable") @SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages(); List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new AdIdPackage());
return packages; return packages;
} }

View File

@@ -5,7 +5,7 @@ buildscript {
buildToolsVersion = "33.0.0" buildToolsVersion = "33.0.0"
minSdkVersion = 21 minSdkVersion = 21
compileSdkVersion = 33 compileSdkVersion = 33
targetSdkVersion = 33 targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620" ndkVersion = "23.1.7779620"

View File

@@ -21,7 +21,7 @@
"react": "18.2.0", "react": "18.2.0",
"react-native": "0.72.10", "react-native": "0.72.10",
"react-native-animatable": "^1.4.0", "react-native-animatable": "^1.4.0",
"react-native-background-actions": "^4.0.1", "react-native-background-actions": "^4.1.0",
"react-native-device-info": "14.0.4", "react-native-device-info": "14.0.4",
"react-native-fs": "^2.20.0", "react-native-fs": "^2.20.0",
"react-native-gesture-handler": "~2.9.0", "react-native-gesture-handler": "~2.9.0",

View File

@@ -1,15 +0,0 @@
diff --git a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
index 9900fc0..d810b1c 100644
--- a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
+++ b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
@@ -41,8 +41,8 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
notificationIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
}
final PendingIntent contentIntent;
- if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- contentIntent = PendingIntent.getActivity(context,0, notificationIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT);
+ if (Build.VERSION.SDK_INT >= 34) { // Android 14 (UPSIDE_DOWN_CAKE)
+ contentIntent = PendingIntent.getActivity(context,0, notificationIntent, PendingIntent.FLAG_MUTABLE | 0x01000000); // FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@@ -0,0 +1,202 @@
diff --git a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/BackgroundTaskOptions.java b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/BackgroundTaskOptions.java
index 35d8f87..175cab1 100644
--- a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/BackgroundTaskOptions.java
+++ b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/BackgroundTaskOptions.java
@@ -24,25 +24,21 @@ public final class BackgroundTaskOptions {
}
public BackgroundTaskOptions(@NonNull final ReactContext reactContext, @NonNull final ReadableMap options) {
- // Create extras
extras = Arguments.toBundle(options);
if (extras == null)
throw new IllegalArgumentException("Could not convert arguments to bundle");
- // Get taskTitle
try {
if (options.getString("taskTitle") == null)
throw new IllegalArgumentException();
} catch (Exception e) {
throw new IllegalArgumentException("Task title cannot be null");
}
- // Get taskDesc
try {
if (options.getString("taskDesc") == null)
throw new IllegalArgumentException();
} catch (Exception e) {
throw new IllegalArgumentException("Task description cannot be null");
}
- // Get iconInt
try {
final ReadableMap iconMap = options.getMap("taskIcon");
if (iconMap == null)
@@ -55,7 +51,6 @@ public final class BackgroundTaskOptions {
if (iconPackage == null)
throw new IllegalArgumentException();
} catch (Exception e) {
- // Get the current package as default
iconPackage = reactContext.getPackageName();
}
final int iconInt = reactContext.getResources().getIdentifier(iconName, iconType, iconPackage);
@@ -65,7 +60,6 @@ public final class BackgroundTaskOptions {
} catch (Exception e) {
throw new IllegalArgumentException("Task icon not found");
}
- // Get color
try {
final String color = options.getString("color");
extras.putInt("color", Color.parseColor(color));
@@ -114,7 +108,6 @@ public final class BackgroundTaskOptions {
try {
types = extras.getStringArrayList("foregroundServiceType");
} catch (ClassCastException e) {
- // If the stored value is not an ArrayList<String>, treat it as no types.
return 0;
}
if (types == null) {
@@ -156,31 +149,6 @@ public final class BackgroundTaskOptions {
return ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
}
return 0;
- case "health":
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- return ServiceInfo.FOREGROUND_SERVICE_TYPE_HEALTH;
- }
- return 0;
- case "remoteMessaging":
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- return ServiceInfo.FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING;
- }
- return 0;
- case "systemExempted":
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- return ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED;
- }
- return 0;
- case "shortService":
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- return ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
- }
- return 0;
- case "specialUse":
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- return ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE;
- }
- return 0;
default:
return 0;
}
diff --git a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
index 963b788..b75c098 100644
--- a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
+++ b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
@@ -5,6 +5,7 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -14,21 +15,22 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
-import androidx.core.app.ServiceCompat;
import com.facebook.react.HeadlessJsTaskService;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
+import java.lang.reflect.Method;
+
final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
public static final int SERVICE_NOTIFICATION_ID = 92901;
private static final String CHANNEL_ID = "RN_BACKGROUND_ACTIONS_CHANNEL";
+ private static final int FOREGROUND_SERVICE_TYPE_DATA_SYNC = 1;
@SuppressLint("UnspecifiedImmutableFlag")
@NonNull
public static Notification buildNotification(@NonNull Context context, @NonNull final BackgroundTaskOptions bgOptions) {
- // Get info
final String taskTitle = bgOptions.getTaskTitle();
final String taskDesc = bgOptions.getTaskDesc();
final int iconInt = bgOptions.getIconInt();
@@ -38,7 +40,6 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
if (linkingURI != null) {
notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkingURI));
} else {
- //as RN works on single activity architecture - we don't need to find current activity on behalf of react context
notificationIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (notificationIntent == null) {
notificationIntent = new Intent(Intent.ACTION_MAIN)
@@ -46,13 +47,11 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
.setPackage(context.getPackageName());
}
}
- final PendingIntent contentIntent;
int pendingIntentFlags = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- // IMMUTABLE is available and recommended from API 23+
pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE;
}
- contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, pendingIntentFlags);
+ final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, pendingIntentFlags);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setContentTitle(taskTitle)
.setContentText(taskDesc)
@@ -93,21 +92,22 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
throw new IllegalArgumentException("Extras cannot be null");
}
final BackgroundTaskOptions bgOptions = new BackgroundTaskOptions(extras);
- createNotificationChannel(bgOptions.getTaskTitle(), bgOptions.getTaskDesc()); // Necessary creating channel for API 26+
- // Create the notification
+ createNotificationChannel(bgOptions.getTaskTitle(), bgOptions.getTaskDesc());
final Notification notification = buildNotification(this, bgOptions);
try {
- ServiceCompat.startForeground(
- this,
- SERVICE_NOTIFICATION_ID,
- notification,
- bgOptions.getForegroundServiceType()
- );
+ int fgType = bgOptions.getForegroundServiceType();
+ if (fgType == 0) {
+ fgType = FOREGROUND_SERVICE_TYPE_DATA_SYNC;
+ }
+ if (Build.VERSION.SDK_INT >= 34) {
+ startForegroundWithType(SERVICE_NOTIFICATION_ID, notification, fgType);
+ } else {
+ startForeground(SERVICE_NOTIFICATION_ID, notification);
+ }
} catch (RuntimeException e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& e instanceof android.app.ForegroundServiceStartNotAllowedException) {
- // Android 12+: not allowed to start foreground service from background
stopSelf(startId);
return START_NOT_STICKY;
}
@@ -116,16 +116,13 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
return super.onStartCommand(intent, flags, startId);
}
- @Override
- public void onTimeout(int startId) {
- super.onTimeout(startId);
- stopSelf(startId);
- }
-
- @Override
- public void onTimeout(int startId, int fgsType) {
- super.onTimeout(startId, fgsType);
- stopSelf(startId);
+ private void startForegroundWithType(int id, Notification notification, int fgType) {
+ try {
+ Method method = Service.class.getMethod("startForeground", int.class, Notification.class, int.class);
+ method.invoke(this, id, notification, fgType);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to start foreground service with type", e);
+ }
}
private void createNotificationChannel(@NonNull final String taskTitle, @NonNull final String taskDesc) {

View File

@@ -5,6 +5,8 @@ import {
AppStateStatus, AppStateStatus,
Image, Image,
Modal, Modal,
NativeModules,
Platform,
ScrollView, ScrollView,
StyleSheet, StyleSheet,
Switch, Switch,
@@ -145,8 +147,7 @@ interface HomeScreenState {
export default class HomeScreen extends Component<any, HomeScreenState> { export default class HomeScreen extends Component<any, HomeScreenState> {
private deviceId: string; private deviceId: string;
private androidId: string; private androidId: string;
private adid: string = '';
private tuneUserId: string;
private clientId: string = ''; private clientId: string = '';
@@ -185,12 +186,39 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
expandedBoundWalletGroups: {}, expandedBoundWalletGroups: {},
}; };
this.deviceId = DeviceInfo.getUniqueIdSync(); this.deviceId = DeviceInfo.getUniqueIdSync();
this.tuneUserId = "yz8mxybytus";//Math.random().toString(36).substring(2, 15);
this.androidId = DeviceInfo.getAndroidIdSync(); this.androidId = DeviceInfo.getAndroidIdSync();
} }
private loadAdid = async (): Promise<string> => {
if (Platform.OS !== 'android' || !NativeModules.AdId?.getAdvertisingId) {
this.adid = '';
return '';
}
try {
const id = await NativeModules.AdId.getAdvertisingId();
this.adid = (id || '').trim();
} catch (e) {
console.log('[ADID] getAdvertisingId failed:', e);
this.adid = '';
}
return this.adid;
};
private ensureMobikwikOtpParams = async () => {
const adid = this.adid || await this.loadAdid();
if (!adid) {
throw new Error('无法获取 GAID (广告 ID),请确认已安装 Google Play 服务且未关闭广告 ID');
}
return {
androidId: this.androidId,
adid,
tuneUserId: adid,
};
};
async componentDidMount() { async componentDidMount() {
await loadServerDomain(); await loadServerDomain();
await this.loadAdid();
const tokenAutoRebind = getTokenAutoRebindEnabled(); const tokenAutoRebind = getTokenAutoRebindEnabled();
this.setState({ tokenAutoRebind }); this.setState({ tokenAutoRebind });
proxyBackgroundService.setTokenAutoRebindEnabled(tokenAutoRebind); proxyBackgroundService.setTokenAutoRebindEnabled(tokenAutoRebind);
@@ -705,12 +733,14 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
<MobikwikPersonalOTPBind <MobikwikPersonalOTPBind
isDebug isDebug
initialMobile={bindPrefillMobile} initialMobile={bindPrefillMobile}
onRequestOTP={async (wt, p) => onRequestOTP={async (wt, p) => {
this.wrapOtpCall(() => Api.instance.requestOTP(wt, p.mobile, { try {
androidId: this.androidId, const otpParams = await this.ensureMobikwikOtpParams();
tuneUserId: this.tuneUserId, return this.wrapOtpCall(() => Api.instance.requestOTP(wt, p.mobile, otpParams));
})) } catch (e) {
} return { success: false, message: (e as Error).message };
}
}}
onVerifyOTP={async (wt, p) => onVerifyOTP={async (wt, p) =>
this.wrapOtpCall(() => Api.instance.verifyOTP(wt, p.mobile, p.otp, p)) this.wrapOtpCall(() => Api.instance.verifyOTP(wt, p.mobile, p.otp, p))
} }

View File

@@ -4,6 +4,7 @@ import {
onProxyMessage, onProxyMessage,
proxySendMessage, proxySendMessage,
openPaytmPayToBank, openPaytmPayToBank,
openPaytmPayToBank2,
openMobikwikPayToBank, openMobikwikPayToBank,
openPhonePePayToBank, openPhonePePayToBank,
openFreechargePayToBank, openFreechargePayToBank,
@@ -34,6 +35,12 @@ export default function TestScreen() {
.catch(error => Alert.alert('Transfer Failed', String(error))); .catch(error => Alert.alert('Transfer Failed', String(error)));
}; };
const handlePaytmPayToBank2 = () => {
openPaytmPayToBank2('Harshpreet singh', '01601000068180', 'PSIB0000160', '3', '1234')
.then((result: boolean) => console.log('Paytm Pay To Bank2', result ? 'Success' : 'Failed'))
.catch((error: unknown) => Alert.alert('Transfer Failed', String(error)));
};
const handleMobikwikPayToBank = () => { const handleMobikwikPayToBank = () => {
openMobikwikPayToBank('Anmol', '5521101002938', 'CNRB0005521', '12') openMobikwikPayToBank('Anmol', '5521101002938', 'CNRB0005521', '12')
.then(result => console.log('Mobikwik Pay To Bank', result ? 'Success' : 'Failed')) .then(result => console.log('Mobikwik Pay To Bank', result ? 'Success' : 'Failed'))
@@ -65,6 +72,9 @@ export default function TestScreen() {
<TouchableOpacity style={[styles.btn, { backgroundColor: '#2ecc71' }]} onPress={handlePaytmPayToBank}> <TouchableOpacity style={[styles.btn, { backgroundColor: '#2ecc71' }]} onPress={handlePaytmPayToBank}>
<Text style={styles.btnText}>Paytm Pay To Bank Test</Text> <Text style={styles.btnText}>Paytm Pay To Bank Test</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={[styles.btn, { backgroundColor: '#27ae60' }]} onPress={handlePaytmPayToBank2}>
<Text style={styles.btnText}>Paytm Pay To Bank2 (deeplink)</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.btn, { backgroundColor: '#2ecc33' }]} onPress={handleMobikwikPayToBank}> <TouchableOpacity style={[styles.btn, { backgroundColor: '#2ecc33' }]} onPress={handleMobikwikPayToBank}>
<Text style={styles.btnText}>Mobikwik Pay To Bank Test</Text> <Text style={styles.btnText}>Mobikwik Pay To Bank Test</Text>
</TouchableOpacity> </TouchableOpacity>