0.4.0 • Published 3 years ago

react-native-android-whitelist v0.4.0

Weekly downloads
138
License
MIT
Repository
github
Last release
3 years ago

react-native-android-whitelist

Many android manufactuers have power saving optimizations that prevents applications from receiving push notifications while the app is not active. This package will help you alert the user to whitelist your app so that push notifications will arrive more reliably. To learn more about this problem, please visit https://dontkillmyapp.com/

Supported Manufacturers:

ManufacturerPower Saving Feature
AsusAuto-Start Manager
MIUIAuto-Start Manager
LetvAuto-Boot Manager
HuaweiProtected Apps
ColorosStartup App List
OppoStartup App
VivoBackground Startup Manager
SamsungBattery Activity

screenshot

Getting started

$ npm install react-native-android-whitelist --save

React Native versions < 0.60

Please use this the reverse-jetify functionality of the following library to convert back from AndroidX: https://github.com/mikehardy/jetifier

Automatic installation

$ react-native link react-native-android-whitelist

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import co.reclub.android.whitelist.RNAndroidWhitelistPackage; to the imports at the top of the file
  • Add new RNAndroidWhitelistPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-android-whitelist'
    project(':react-native-android-whitelist').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-whitelist/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
    implementation project(':react-native-android-whitelist')

Usage

import AndroidWhitelist from 'react-native-android-whitelist';

const config = {
  title: 'Android Whitelist',
  text: 'To ensure timely delivery of push notifications, please whitelist our app.',
  doNotShowAgainText: 'Do not show again',
  positiveText: 'Whitelist',
  negativeText: 'Cancel'
}

AndroidWhitelist.alert(config)