Last active
February 27, 2019 06:35
-
-
Save mahipalsingh7/c1e9ac5197708ba8006fd114c895750b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Steps to add native application in | |
Supportive Links : | |
https://facebook.github.io/react-native/docs/native-modules-setup | |
https://facebook.github.io/react-native/docs/native-modules-ios | |
https://facebook.github.io/react-native/docs/native-modules-android | |
https://github.com/BondGoat/react-native-native-video-player/issues/4#issuecomment-281138998 | |
Native Modules · React Native | |
https://facebook.github.io | |
1. Open Terminal, Select Your React-native project path | |
2. Run command : $ npm install -g react-native-create-library | |
3. $ react-native-create-library <Name_Of_Lib> | |
4. Now Navigate to <Name_Of_Lib> path | |
5. Run $ npm install | |
6. Under <Name_Of_Lib> you will get Three folders iOs, Android , Windows | |
** Now Suppose we need to play youtube Player with native code…. | |
Functionality : we pass Youtube id from main react-native project.. which will be use in native player. | |
7. Open your Main iOS Project under react native & add pod file | |
8. Add pod 'youtube-ios-player-helper', '~> 0.1.4' | |
9. Pod install. | |
10. YOu can create a separate project and than add all your files with Main Storyboard under main react-native iOS folder | |
11. Open again <Name_Of_Lib> iOS project | |
12. You will get .h/.m | |
13. in .h file of <Name_Of_Lib> add method you which call from react-native project | |
14. In .m file of <Name_Of_Lib> define method which perform actions | |
Here..functionality work like this.. | |
you already added your seperate module in main React-native folder, so you need to pass & open your initial controller of main storyboard. | |
So, | |
So, inside .m file method (<Name_of_Lib>) add appdelegate code. | |
AppDelegate appDelegate = (AppDelegate )[UIApplication sharedApplication].delegate; | |
[appDelegate goToYoutubeView:videoID]; | |
And Under main react-native appdelegate add one method which navigate to screen on main storyboard controller that added by you. | |
In Appldelegate .m (React-native folder) | |
// this method will be called from the RCTBridge | |
- (void) goToYoutubeView:(NSString*)url { | |
NSLog(@"RN binding - Native View - MyViewController.swift - Load From"); | |
SingleVideoViewController vc = (SingleVideoViewController) [UIStoryboard storyboardWithName:@"Main" bundle:nil].instantiateInitialViewController; | |
vc.youtubeUrl = url; | |
[self.window.rootViewController presentViewController:vc animated:true completion:nil]; | |
} | |
This will be called as RCTBridge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment