
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Get device heading information on iOS or Android
##What Report back device orientation in degrees, 0-360, with 0 being North.
####Example
const { DeviceEventEmitter } = require('react-native');
const ReactNativeHeading = require('react-native-heading');
//....
componentDidMount() {
ReactNativeHeading.start(1)
.then(didStart => {
this.setState({
headingIsSupported: didStart,
})
})
DeviceEventEmitter.addListener('headingUpdated', data => {
console.log('New heading is:', data.heading);
});
}
componentWillUnmount() {
ReactNativeHeading.stop();
DeviceEventEmitter.removeAllListeners('headingUpdated');
}
//...
####API
start(filter)
- Start receiving heading updates. Accepts an optional filter param (int) to ignore heading changes less than the spcified threshold. The default value is 5. Returns a promise which can be used to determine if heading updates are suported by the device.
stop
- Stop receiving heaing updates (don't forget to remove the headingUpdated
listener)
##Setup
npm install --save react-native-heading
###iOS
###Android #####Step 1 - Update Gradle Settings
// file: android/settings.gradle
...
include ':react-native-heading'
project(':react-native-heading').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-heading/android')
#####Step 2 - Update Gradle Build
// file: android/app/build.gradle
...
dependencies {
...
compile project(':react-native-heading')
}
#####Step 3 - Register React Package
...
import com.joshblour.reactnativeheading.ReactNativeHeadingPackage; // <--- import
public class MainActivity extends ReactActivity {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeHeadingPackage() // <------ add the package
);
}
...
}
FAQs
Get device heading information on iOS or Android
We found that rn-heading demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.