Last active
February 27, 2019 06:27
-
-
Save mahipalsingh7/7e47a257e589e7070d64d6c2afa1f78d 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
For android | |
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 | |
Native Modules · React Native | |
https://facebook.github.io | |
15. First create a separate native code (new Project) | |
16. Now suppose you have file like : layout file (add this file under layout file), Package file, Module File , & your code files (add these files under main—>java —> com —> bundle name-> paste & update existing file) | |
17. Under Module file add @ReactMethod method which will open your Activity on current intent of application ReactMethod method will call from your main react-native project | |
Sample code here | |
@ReactMethod | |
public void showYoutubePlayer(String urlStr) { | |
ReactApplicationContext context = getReactApplicationContext(); | |
Intent intent = new Intent(context, YoutubeplayerAct.class); | |
intent.putExtra("videourl",urlStr); | |
context.startActivity(intent); | |
// Intent intnt=new Intent(getCurrentActivity(), YoutubeplayerAct.class); | |
// intnt.putExtra("videourl",urlStr); | |
// startActivity(intnt); | |
// Toast.makeText(getReactApplicationContext(), urlStr).show(); | |
} | |
18. Add activity under Manifest android:name="com.reactlibrary.YoutubeplayerAct" | |
19. Now at last copy your <Name_Of_Lib> to node_module folder | |
20. Run react-native link | |
21. Open your main React -native folder, Open your Controller from where you wanna to open Native module | |
In that controller first import <NativeModule> | |
Now call the bridge method like this.. | |
var RNYoutubeios = NativeModules.RNYoutubeios; | |
RNYoutubeios.showYoutubePlayer(urlID); | |
------------- | |
Additional for android | |
open Package.json | |
under dependencies | |
add Lib: "screenDetector": "file:screenDetector" | |
under Setting.gradle | |
add | |
include ':screenDetector' | |
project(':screenDetector').projectDir = new File(rootProject.projectDir, '../node_modules/screenDetector/android') | |
react-nativ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment