1.1.0 • Published 4 months ago
kovalee-react-native-sdk v1.1.0
Kovalee React Native SDK
Wrapper around the KovaleeSDK for iOS
Installation
npm install kovalee-react-native-sdk
How 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.xcodeproj
with 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.xcworkspace
with XCode - Make sure you ran
yarn install
andpod install
in theios/
folder - In
example/src/App.tsx
:import { multiply } from 'kovalee-rn-sdk'; // call multiply() wherever you want in the code
- Run
yarn start
in a terminal - Build the app either in XCode or by running
yarn ios
in a terminal
You're done! 🎉
How to release a new version
- Make sure you pull
master
and 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 publish
in your terminal at the root of the project - The credentials to login to npm and the OTP are in 1Password