Created
September 14, 2023 21:05
-
-
Save joeporpeglia/05fafd2328a54bc5eb71ce1bea37a9ce to your computer and use it in GitHub Desktop.
Expo config plugin for LiveKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withLivekit(config: ExpoConfig): ExpoConfig { | |
config = withLivekitAndroid(config); | |
config = withLivekitIOS(config); | |
return config; | |
} | |
function withLivekitAndroid(expoConfig: ExpoConfig): ExpoConfig { | |
return withMainApplication(expoConfig, (config) => { | |
let contents = config.modResults.contents; | |
// Replace com.example with your package name | |
contents = contents.replace( | |
'package com.example;', | |
'package com.example;\nimport com.livekit.reactnative.LiveKitReactNative;' | |
); | |
contents = contents.replace( | |
'super.onCreate();', | |
'super.onCreate();\nLiveKitReactNative.setup(this);' | |
); | |
config.modResults.contents = contents; | |
return config; | |
}); | |
} | |
function withLivekitIOS(expoConfig: ExpoConfig): ExpoConfig { | |
return withAppDelegate(expoConfig, (config) => { | |
let contents = config.modResults.contents; | |
contents = contents.replace( | |
'#import "AppDelegate.h"', | |
'#import "AppDelegate.h"\n#import "LivekitReactNative.h"' | |
); | |
contents = contents.replace( | |
'self.moduleName = @"main";', | |
'self.moduleName = @"main";\n[LivekitReactNative setup];' | |
); | |
config.modResults.contents = contents; | |
return config; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment