Skip to content

Commit

Permalink
Fix iOS AppDelegate issue and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Aug 30, 2024
1 parent 03feaf4 commit 16fb183
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: checkout
uses: actions/[email protected]
- name: installation of node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: publish
Expand Down
2 changes: 1 addition & 1 deletion example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ReactNativeAntMediaExample",
"displayName": "ReactNativeAntMedia Example"
"displayName": "ReactNative AntMedia Example"
}
4 changes: 2 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AppRegistry } from 'react-native';
//import App from './src/App';
import App from './src/Play';
//import App from './src/Play';
//import App from './src/Peer';
//import App from './src/Conference';
import App from './src/Conference';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => App);
97 changes: 10 additions & 87 deletions example/ios/ReactNativeAntMediaExample/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -1,63 +1,25 @@
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <RCTAppSetupUtils.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTAppSetupPrepareApp(application, true);

RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"ReactNativeAntMediaExample", nil, true);

if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.moduleName = @"ReactNativeAntMediaExample";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
}

- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
Expand All @@ -66,43 +28,4 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
#endif
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

@end
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import InCallManager from 'react-native-incall-manager';

export default function App() {
var defaultStreamName = 'streamTest1';
const webSocketUrl = 'ws://server.com:5080/WebRTCAppEE/websocket';
const webSocketUrl = 'ws://test.antmedia.io:5080/WebRTCAppEE/websocket';
//or webSocketUrl: 'wss://server.com:5443/WebRTCAppEE/websocket',

const streamNameRef = useRef<string>(defaultStreamName);
Expand Down
2 changes: 1 addition & 1 deletion example/src/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'react-native';

var defaultStreamName = 'streamTest1';
const webSocketUrl = 'ws://server.com:5080/WebRTCAppEE/websocket';
const webSocketUrl = 'ws://test.antmedia.io:5080/WebRTCAppEE/websocket';
//or webSocketUrl: 'wss://server.com:5443/WebRTCAppEE/websocket',

const Chat: React.FC = () => {
Expand Down
6 changes: 3 additions & 3 deletions example/src/Conference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var publishStreamId:string;

export default function Conference() {
var defaultRoomName = 'room1';
const webSocketUrl = 'ws://server.com:5080/WebRTCAppEE/websocket';
const webSocketUrl = 'ws://test.antmedia.io:5080/WebRTCAppEE/websocket';
//or webSocketUrl: 'wss://server.com:5443/WebRTCAppEE/websocket',

const [localMedia, setLocalMedia] = useState('');
Expand Down Expand Up @@ -85,7 +85,7 @@ export default function Conference() {
}
},
callbackError: (err: any, data: any) => {
if (err === "no_active_streams_in_room" || err === "no_stream_exists") {
if (err === "no_active_streams_in_room" || err === "no_stream_exist") {
// it throws this error when there is no stream in the room
// so we shouldn't reset streams list
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ export default function Conference() {
});
return;
}
console.warn("clearing all the remote renderer", remoteTracks, streamId)
console.info("clearing all the remote renderer", remoteTracks, streamId)
setremoteTracks([]);
};

Expand Down
2 changes: 1 addition & 1 deletion example/src/Peer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import InCallManager from 'react-native-incall-manager';

export default function App() {
var defaultStreamName = 'stream1';
const webSocketUrl = 'ws://server.com:5080/WebRTCAppEE/websocket';
const webSocketUrl = 'ws://test.antmedia.io:5080/WebRTCAppEE/websocket';
//or webSocketUrl: 'wss://server.com:5443/WebRTCAppEE/websocket',

const [localMedia, setLocalMedia] = useState('');
Expand Down
2 changes: 1 addition & 1 deletion example/src/Play.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {useAntMedia, rtc_view} from '@antmedia/react-native-ant-media';

export default function App() {
var defaultStreamName = 'stream1';
const webSocketUrl = 'ws://server.com:5080/WebRTCAppEE/websocket';
const webSocketUrl = 'ws://test.antmedia.io:5080/WebRTCAppEE/websocket';
//or webSocketUrl: 'wss://server.com:5443/WebRTCAppEE/websocket',

const streamNameRef = useRef<string>(defaultStreamName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antmedia/react-native-ant-media",
"version": "1.0.8",
"version": "1.0.9",
"description": "Ant Media Server WebRTC React Native SDK and Reference Project",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 16fb183

Please sign in to comment.