1.3.1 • Published 1 year ago
kovalee-react-native-sdk v1.3.1
Kovalee React Native SDK
Wrapper around the KovaleeSDK for iOS
Installation
npm install kovalee-react-native-sdkHow to make changes to the RN SDK
iOS side
Let's say you want to add a function called multiply(a, b) to the SDK
- Open
ios/KovaleeRnSdk.xcodeprojwith XCode - In
KovaleeRnSdk.swift, add the logic of the function:
@objc(multiply:withB:withResolver:withRejecter:)
func multiply(a: Float, b: Float, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
resolve(a*b)
}- In
KovaleeRnSdk.mm, export the method so it is available in React Native:
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)React Native side
- In
/src/index.tsx, define the new method we just add in the XCode project:
export function multiply(a: number, b: number): Promise<number> {
return KovaleeRnSdk.multiply(a, b);
}You're done! 🎉
How to test the RN SDK
Let's say we want to test the method multiply(a, b) we created above
- Open
example/ios/KovaleeRnSdkExample.xcworkspacewith XCode - Make sure you ran
yarn installandpod installin theios/folder - In
example/src/App.tsx:import { multiply } from 'kovalee-rn-sdk'; // call multiply() wherever you want in the code - Run
yarn startin a terminal - Build the app either in XCode or by running
yarn iosin a terminal
You're done! 🎉
How to release a new version
- Make sure you pull
masterand that you are up to date - Increment the version of the package in
package.json - Commit the change on GitHub with the following commit message:
chore: release vx.x.x - Run
npm publishin your terminal at the root of the project - The credentials to login to npm and the OTP are in 1Password