From 5404b7c18e310f683eee9db1f74a78a34d74f086 Mon Sep 17 00:00:00 2001 From: 223880 Date: Mon, 18 Nov 2024 08:01:26 -0300 Subject: [PATCH] Initial ios library --- ios/ios.swift | 9 +++++++++ ios/library.m | 14 ++++++++++++++ src/index.ts | 12 ++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 ios/ios.swift create mode 100644 ios/library.m 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 };