We currently don’t provide a React Native module to use the TMD SDK from a React Native project. However, it is possible to make one by following the recommendations from the React Native documentation on how to make an iOS Native Module.
As a starting point, here is how you would start and stop the TMD from React Native:
// RCTTmdModule.h
#import <React/RCTBridgeModule.h>
@interface RCTTmdModule : NSObject <RCTBridgeModule>
@end
// RCTTmdModule.m
#import "RCTTmdModule.h"
#import <MOPRIMTmdSdk/MOPRIMTmdSdk.h>
@implementation RCTTmdModule
// Export a module named RCTTmdModule:
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(start)
{
[TMD start];
}
RCT_EXPORT_METHOD(stop)
{
[TMD stop];
}
@end
// NativeTmdModule.js
import { NativeModules } from 'react-native';
const { TmdModule } = NativeModules;
interface TmdInterface {
start(): void;
stop(): void;
}
export default TmdModule;
// App.js
import TmdModule from './NativeTmdModule';
const onPressTmdStart = () => {
TmdModule.start();
};
const onPressTmdStop = () => {
TmdModule.stop();
};