Skip to content

Commit

Permalink
fix: compiler error on android
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed Aug 29, 2024
1 parent bb942a8 commit c22010a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.candlefinance.send

import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule

Expand All @@ -11,10 +12,8 @@ class SendModule(reactContext: ReactApplicationContext) :
return NAME
}

// Example method
// See https://reactnative.dev/docs/native-modules-android
override fun multiply(a: Double, b: Double): Double {
return a * b
override fun send(request: String?, promise: Promise?) {
TODO("Not yet implemented")
}

companion object {
Expand Down
8 changes: 4 additions & 4 deletions packages/npm/send/src/Send.nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ export interface Request {
query: Parameters
header: Parameters
method: string
body: string | null
body: string | undefined
utf8ContentTypes: string[]
}

export interface Response {
statusCode: number
header: Parameters
body: string | null
body: string | undefined
}

enum Code {
export enum Code {
RESPONSE_INVALID,
REQUEST_INVALID,
NETWORK_ERROR,
NO_RESPONSE,
NON_UTF8_RESPONSE_BODY,
NON_UTF8_REQUEST_BODY,
INVALID_REQUEST_PATH_OR_QUERY_PARAMETERS,
IVNALID_REQUEST_BASE_URL,
INVALID_REQUEST_BASE_URL,
NON_BASE64_REQUEST_BODY,
INVALID_RESPONSE_HEADER_PARAMETERS,
UNEXPECTED,
Expand Down
15 changes: 13 additions & 2 deletions packages/npm/send/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Platform } from 'react-native'
import { NitroModules } from 'react-native-nitro-modules'
import type { Request, Send, SendResult } from './Send.nitro'
import { Code, type Request, type Send, type SendResult } from './Send.nitro'
export * from './Send.nitro'

export type Method =
Expand All @@ -18,5 +19,15 @@ const Send = NitroModules.createHybridObject<Send>('Send')
export async function send(
request: Request & { method: Method }
): Promise<SendResult> {
return Send.send(request)
if (Platform.OS === 'ios') {
return Send.send(request)
} else {
return {
error: {
code: Code.NO_RESPONSE,
message: 'Platform is not supported',
},
response: undefined,
}
}
}

0 comments on commit c22010a

Please sign in to comment.