A library to get a project's package name in Android so you can link to the app's Play Store listing page for reviews/sharing. If this module is used in iOS it will get the Bundle Identifier string instead.
$ npm install react-native-package-name --save
$ react-native link react-native-package-name
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-package-name
and addRNPackageName.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPackageName.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNPackageNamePackage;
to the imports at the top of the file - Add
new RNPackageNamePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-package-name' project(':react-native-package-name').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-package-name/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-package-name')
import { PackageName } from 'react-native-package-name';
let packageName = PackageName.getPackageName();
// Do something with packageName