diff --git a/ios/ios.swift b/ios/ios.swift new file mode 100644 index 0000000..ad3cba6 --- /dev/null +++ b/ios/ios.swift @@ -0,0 +1,9 @@ +import Foundation + +@objc(YourLibrary) +class YourLibrary: NSObject { + @objc + func sampleMethod(_ input: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + resolve("iOS: " + input) + } +} diff --git a/ios/library.m b/ios/library.m new file mode 100644 index 0000000..17ba50b --- /dev/null +++ b/ios/library.m @@ -0,0 +1,14 @@ +#import + +@interface YourLibrary : NSObject +@end + +@implementation YourLibrary + +RCT_EXPORT_MODULE(); + +RCT_EXPORT_METHOD(sampleMethod:(NSString *)input resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + resolve([@"iOS: " stringByAppendingString:input]); +} + +@end diff --git a/src/index.ts b/src/index.ts index 492ad44..e239fff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import bitcoin from 'bitcoinjs-lib'; import axios from 'axios'; +import { NativeModules, Platform } from 'react-native'; // Define types for UTXO and PayJoin response interface Utxo { @@ -79,5 +80,16 @@ function fetchUtxos(senderAddress: string): Utxo[] | PromiseLike { throw new Error('Function not implemented.'); } + +const { YourLibrary } = NativeModules; + +const sampleMethod = async (input: string): Promise => { + return await YourLibrary.sampleMethod(input); +}; + +export default { + sampleMethod, +}; + export { createInitialPayJoinTx, sendPayJoinRequest, finalizeAndBroadcast, broadcastTransaction };