Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions ios/DetectFrida.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#import "JailBrokenHelper.h"

@implementation DetectFrida


RCT_EXPORT_MODULE()

// Example method
Expand Down Expand Up @@ -47,6 +49,18 @@ - (BOOL)isJailBroken {
RCT_REMAP_METHOD(isJailBroken,
isJailBrokenWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self isJailBroken: resolve reject:reject];
}

RCT_EXPORT_METHOD(closeAppAfterDelay:(double)delay) {
[self closeApp:delay];
}

- (void)detectRoot:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
reject(@"-1", @"This function is only for Android", nil);
}

- (void)isJailBroken:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
@try {
BOOL isJailBroken = [self isJailBroken];
resolve(@{@"isRooted": @(isJailBroken)});
Expand All @@ -57,10 +71,11 @@ - (BOOL)isJailBroken {
}
}

RCT_EXPORT_METHOD(closeAppAfterDelay:(double)delay) {
[self closeApp:delay];
}

#ifdef RCT_NEW_ARCH_ENABLED

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
return std::make_shared<facebook::react::NativeDetectFridaSpecJSI>(params);
}

#endif
@end
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@
"name": "RNDetectFridaSpec",
"type": "modules",
"jsSrcsDir": "src",
"outputDir": {
"ios": "ios/generated",
"android": "android/generated"
},
"includesGeneratedCode": true,
"android": {
"javaPackageName": "com.detectfrida"
},
"ios": {
"modulesProvider": {
"DetectFrida": "DetectFrida"
}
}
}
}
1 change: 0 additions & 1 deletion react-native-detect-frida.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/imanshul/react-native-detect-frida.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,cpp}"
s.private_header_files = "ios/generated/**/*.h"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down
4 changes: 2 additions & 2 deletions src/NativeDetectFrida.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TurboModule } from 'react-native';
import { type TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

export interface Spec extends TurboModule {
Expand All @@ -21,4 +21,4 @@ export interface Spec extends TurboModule {
closeAppAfterDelay?(delay: number): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('DetectFrida');
export default TurboModuleRegistry.get<Spec>('DetectFrida');
20 changes: 4 additions & 16 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { NativeModules, Platform } from 'react-native';
import type { RootCheckResult } from './ValueTypes';
import NativeDetectFrida from './NativeDetectFrida';

const LINKING_ERROR =
`The package 'react-native-detect-frida' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

const DetectFrida = NativeModules.DetectFrida
? NativeModules.DetectFrida
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
const DetectFrida = NativeDetectFrida
? NativeDetectFrida
: NativeModules.DetectFrida;

const isAndroid = () => {
return Platform.OS === 'android';
Expand Down
Loading