# React Native Push Notifications
[![npm version](https://badge.fury.io/js/react-native-push-notification.svg?update=9)](http://badge.fury.io/js/react-native-push-notification)
[![npm downloads](https://img.shields.io/npm/dm/react-native-push-notification.svg?update=9)](http://badge.fury.io/js/react-native-push-notification)
React Native Local and Remote Notifications for iOS and Android
## State of the repository
This repository is not actively maintained. The main reason is time. The second one is probably the complexity of notifications on both iOS and Android.
Since this project probably need a huge refactor to fix some issue or to implement new features. I think you should probably consider these alternatives: [Notifee](https://notifee.app) free since september or [react-native-notifications](https://github.com/wix/react-native-notifications).
If you are interested in being a maintainer of this project, feel free to ask in issues.
## ð Version 7.x is live ! ð
Check out for changes and migration in the CHANGELOG:
[Changelog](https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md)
# Supporting the project
Maintainers are welcome ! Feel free to contact me :wink:
## Changelog
Changelog is available from version 3.1.3 here: [Changelog](https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md)
## Installation
### NPM
```
npm install --save react-native-push-notification
```
### Yarn
```
yarn add react-native-push-notification
```
**NOTE: If you target iOS you also need to follow the [installation instructions for PushNotificationIOS](https://github.com/react-native-community/react-native-push-notification-ios) since this package depends on it.**
**NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications.**
## Issues
Having a problem? Read the [troubleshooting](./trouble-shooting.md) guide before raising an issue.
## Pull Requests
[Please read...](./submitting-a-pull-request.md)
## iOS manual Installation
The component uses PushNotificationIOS for the iOS part. You should follow their [installation instructions](https://github.com/react-native-community/react-native-push-notification-ios).
## Android manual Installation
**NOTE: `firebase-messaging`, prior to version 15 requires to have the same version number in order to work correctly at build time and at run time. To use a specific version:**
In your `android/build.gradle`
```gradle
ext {
googlePlayServicesVersion = "<Your play services version>" // default: "+"
firebaseMessagingVersion = "<Your Firebase version>" // default: "21.1.0"
// Other settings
compileSdkVersion = <Your compile SDK version> // default: 23
buildToolsVersion = "<Your build tools version>" // default: "23.0.1"
targetSdkVersion = <Your target SDK version> // default: 23
supportLibVersion = "<Your support lib version>" // default: 23.1.1
}
```
**NOTE: localNotification() works without changes in the application part, while localNotificationSchedule() only works with these changes:**
In your `android/app/src/main/AndroidManifest.xml`
```xml
.....
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application ....>
<!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<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"/>
</intent-filter>
</receiver>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
.....
```
If not using a built in Android color (`@android:color/{name}`) for the `notification_color` `meta-data` item.
In `android/app/src/main/res/values/colors.xml` (Create the file if it doesn't exist).
```xml
<resources>
<color name="white">#FFF</color>
</resources>
```
If your app has an @Override on onNewIntent in `MainActivity.java` ensure that function includes a super call on onNewIntent (if your `MainActivity.java` does not have an @Override for onNewIntent skip this):
```java
@Override
public void onNewIntent(Intent intent) {
...
super.onNewIntent(intent);
...
}
```
### If you use remote notifications
Make sure you have installed setup Firebase correctly.
In `android/build.gradle`
```gradle
buildscript {
...
dependencies {
...
classpath('com.google.gms:google-services:4.3.3')
...
}
}
```
In `android/app/build.gradle`
```gradle
dependencies {
...
implementation 'com.google.firebase:firebase-analytics:17.3.0'
...
}
apply plugin: 'com.google.gms.google-services'
```
Then put your `google-services.json` in `android/app/`.
**Note: [firebase/release-notes](https://firebase.google.com/support/release-notes/android)**
> The Firebase Android library `firebase-core` is no longer needed. This SDK included the Firebase SDK for Google Analytics.
>
> Now, to use Analytics or any Firebase product that recommends the use of Analytics (see table below), you need to explicitly add the Analytics dependency: `com.google.firebase:firebase-analytics:17.3.0`.
### If you don't use autolink
In `android/settings.gradle`
```gradle
...
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/android')
```
In your `android/app/build.gradle`
```gradle
dependencies {
...
implementation project(':react-native-push-notification')
...
}
```
Manually register module in `MainApplication.java` (if you did not use `react-native link`):
```java
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; // <--- Import Package
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativePushNotificationPackage() // <---- Add the Package
);
}
};
....
}
```
## Usage
**DO NOT USE `.configure()` INSIDE A COMPONENT, EVEN `App`**
> If you do, notification handlers will not fire, because they are not loaded. Instead, use `.configure()` in the app's first file, usually `index.js`.
```javascript
import PushNotificationIOS from "@react-native-community/
没有合适的资源?快使用搜索试试~ 我知道了~
react-native-push-notification.zip
共106个文件
java:15个
js:14个
png:10个
需积分: 5 0 下载量 116 浏览量
2023-08-18
09:45:31
上传
评论
收藏 335KB ZIP 举报
温馨提示
react-native-push-notification
资源推荐
资源详情
资源评论
收起资源包目录
react-native-push-notification.zip (106个子文件)
gradlew.bat 3KB
BUCK 1KB
.buckconfig 114B
build_defs.bzl 602B
.classpath 352B
.classpath 352B
example.entitlements 246B
.flowconfig 2KB
.gitattributes 16B
.gitignore 798B
.gitignore 541B
build.gradle 8KB
build.gradle 2KB
build.gradle 1KB
settings.gradle 191B
gradlew 6KB
AppDelegate.h 284B
gradle-wrapper.jar 54KB
RNPushNotificationHelper.java 39KB
RNPushNotificationAttributes.java 17KB
RNPushNotification.java 11KB
RNReceivedMessageHandler.java 9KB
RNPushNotificationPicturesAggregator.java 5KB
RNPushNotificationActions.java 4KB
RNPushNotificationListenerService.java 3KB
RNPushNotificationConfig.java 3KB
RNPushNotificationJsDelivery.java 3KB
MainApplication.java 3KB
RNPushNotificationBootEventReceiver.java 2KB
ApplicationBadgeHelper.java 2KB
RNPushNotificationPublisher.java 2KB
ReactNativePushNotificationPackage.java 983B
MainActivity.java 341B
index.js 19KB
NotifService.js 10KB
index.android.js 5KB
App.js 5KB
NotificationHandler.js 2KB
metro.config.js 300B
App-test.js 266B
react-native.config.js 193B
index.js 183B
index.ios.js 152B
.prettierrc.js 120B
index.js 101B
babel.config.js 77B
.eslintrc.js 74B
package.json 861B
Contents.json 849B
package.json 774B
app.json 83B
Contents.json 63B
LICENSE 1KB
Podfile.lock 13KB
AppDelegate.m 4KB
exampleTests.m 2KB
main.m 200B
README.md 31KB
CHANGELOG.md 25KB
trouble-shooting.md 9KB
bug_report.md 2KB
submitting-a-pull-request.md 2KB
question.md 654B
feature_request.md 638B
sample.mp3 50KB
sample.mp3 50KB
.npmignore 985B
.npmignore 7B
project.pbxproj 42KB
Info.plist 2KB
Info.plist 1KB
Info.plist 765B
Info.plist 733B
IDEWorkspaceChecks.plist 238B
ic_launcher_round.png 15KB
ic_launcher_round.png 10KB
ic_launcher.png 9KB
ic_launcher_round.png 7KB
ic_launcher.png 6KB
ic_launcher_round.png 5KB
ic_launcher.png 4KB
ic_launcher.png 3KB
ic_launcher_round.png 3KB
ic_launcher.png 2KB
Podfile 546B
org.eclipse.buildship.core.prefs 383B
org.eclipse.buildship.core.prefs 376B
org.eclipse.buildship.core.prefs 376B
proguard-rules.pro 435B
.project 599B
.project 591B
.project 433B
gradle.properties 1KB
gradle-wrapper.properties 202B
.watchmanconfig 2B
example-tvOS.xcscheme 3KB
example.xcscheme 3KB
contents.xcworkspacedata 225B
LaunchScreen.xib 4KB
AndroidManifest.xml 2KB
共 106 条
- 1
- 2
资源评论
hello_中年人
- 粉丝: 7
- 资源: 324
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功