
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@bitscheme/react-native-push-android
Advanced tools
$ npm install react-native-push-android --save
$ react-native link react-native-push-android
android/app/src/main/java/[...]/MainActivity.javaimport br.com.helderfarias.pushandroid.RNPushAndroidPackage; to the imports at the top of the filenew RNPushAndroidPackage() to the list returned by the getPackages() methodandroid/settings.gradle:
include ':react-native-push-android'
project(':react-native-push-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-android/android')
android/app/build.gradle:
compile project(':react-native-push-android')
dependencies {
...
classpath 'com.android.tools.build:gradle:2.0.0'
+ classpath 'com.google.gms:google-services:3.0.0'
...
...
apply plugin: "com.android.application"
+ apply plugin: 'com.google.gms.google-services'
...
...
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
+ <receiver android:name="br.com.helderfarias.pushandroid.LocalMessagingReceiver" />
+ <receiver android:enabled="true" android:exported="true"
+ android:name="br.com.helderfarias.pushandroid.SystemBootEventReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED"/>
+ <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
+ <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
+ <service android:name="br.com.helderfarias.pushandroid.MessagingService">
+ <intent-filter>
+ <action android:name="com.google.firebase.MESSAGING_EVENT"/>
+ </intent-filter>
+ </service>
+ <service android:name="br.com.helderfarias.pushandroid.InstanceIdService"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
+ </intent-filter>
+ </service>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="fcm.ACTION.HELLO" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
...
This method returns a promise that resolves to either
the notification object if the app was launched by a push notification, or null otherwise.
This method returns a promise with refresh token fcm, or null otherwise.
Attaches a listener to remote or local notification events for app.
Valid events are:
- localNotification: Fired when a local notification is received.
- notification: Fired when a remote notification is received by fcm.
- refreshToken: Fired when a remote token refreshed.
Removes the event listener. Do this in componentWillUnmount to prevent memory leaks.
Create localNotification.
details is an object containing:
- title
- body
- ticket
- auto_cancel
- number
- sub_text
- group
- data
- lights
- priority
- color
- sound
- big_text
- icon
- large_icon
import React, { Component } from "react";
import { AppRegistry, Text, TouchableOpacity, View } from "react-native";
import PushNotificationAndroid from 'react-native-push-android';
export default class Example extends Component {
_localNotificationEvent = null;
_notificationEvent = null;
_refreshTokenEvent = null;
state = {
token: null
};
componentWillMount() {
PushNotificationAndroid.getInitialNotification().then(initial => {
console.log('getInitialNotification => ', initial);
});
PushNotificationAndroid.getToken().then(token => {
this.setState({ token: token });
});
this._localNotificationEvent = PushNotificationAndroid.addEventListener('localNotification', (details) => {
console.log('localNotification => ', details);
});
this._notificationEvent = PushNotificationAndroid.addEventListener('notification', (details) => {
console.log('remoteNotification => ', details);
});
this._refreshTokenEvent = PushNotificationAndroid.addEventListener('refreshToken', (token) => {
console.log('remoteRefreshToken => ', token);
});
}
componentWillUnMount() {
this._localNotificationEvent.remove();
this._notificationEvent.remove();
this._refreshTokenEvent.remove();
// You can remove all listener events
PushNotificationAndroid.removeAllListeners('localNotification');
PushNotificationAndroid.removeAllListeners('notification');
PushNotificationAndroid.removeAllListeners('refreshToken');
}
sendLocalNotificationNormal = () => {
PushNotificationAndroid.notify({
"title": "title",
"body": "body",
"click_action": "fcm.ACTION.HELLO"
});
}
render() {
let { token } = this.state;
return (
<View>
<Text>Token: {this.state.token}</Text>
<TouchableOpacity onPress={this.sendLocalNotificationNormal}>
<Text>Local Notification</Text>
</TouchableOpacity>
</View>
);
}
}
AppRegistry.registerComponent("Example", () => Example);
FAQs
Push Notification Android with FCM
We found that @bitscheme/react-native-push-android 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.