Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aloneszjl/react-native-baidu-push-notification
https://github.com/aloneszjl/react-native-baidu-push-notification
Last synced: about 15 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/aloneszjl/react-native-baidu-push-notification
- Owner: aloneszjl
- Created: 2019-01-10T06:23:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T08:30:49.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T01:13:29.741Z (19 days ago)
- Language: Java
- Size: 480 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-baidu-push-notification
## Getting started
`$ npm install react-native-baidu-push-notification --save`
### Mostly automatic installation
`$ react-native link react-native-baidu-push-notification`
### Manual installation
### iOS manual Installation
The component uses PushNotificationIOS for the iOS part.
[Please see: PushNotificationIOS](https://facebook.github.io/react-native/docs/pushnotificationios.html#content)
#### Android
if you already run react-native link react-native-baidu-push-notification, skip step 1,2,3
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add `import com.alones.reactnative.baidupush.RNPushNotificationPackage;` to the imports at the top of the file
- Add `new RNPushNotificationPackage()` to the list returned by the `getPackages()` method2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-baidu-push-notification'
project(':react-native-baidu-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-baidu-push-notification/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-baidu-push-notification')
```
4. Open up `android/app/src/main/AndroidManifest.xml` add uses-permissions```
```Add permissions to access push notification (replace your app package):
```
```Under `` (replace your app package)
```
``````
```5. copy `node_modules/react-native-baidu-push-notification/android/jniLibs` to `android/app/src/main/jniLibs`
## Usage
```javascript
import RNPushNotification from "react-native-baidu-push-notification";// TODO: What to do with the module?
componentDidMount() {
PushNotification.configure({
popInitialNotification: Platform.select({
ios: false,
android: true,
}),
onRegister(data) {
const token = get(data, 'token');
if (token) {
console.log('yout device token:',token)
}
},
onNotification: this.handlePushNotification,
});
}handlePushNotification = notification => {
console.log(notification)
}
```