├── .buckconfig ├── .eslintignore ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── .yarnclean ├── LICENSE ├── README.md ├── RNCPushNotificationIOS.podspec ├── android ├── app │ ├── BUCK │ ├── build.gradle │ ├── build_defs.bzl │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── pushnotificationios │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties └── settings.gradle ├── babel.config.js ├── docs └── manual-linking.md ├── example ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── App.js ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── example.xcscheme │ ├── example.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── example │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── customSound.wav │ │ ├── example.entitlements │ │ ├── exampleDebug.entitlements │ │ ├── exampleRelease.entitlements │ │ └── main.m │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m └── metro.config.js ├── index.d.ts ├── index.js ├── ios ├── PushNotificationIOS.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── PushNotificationIOS-tvOS.xcscheme │ │ └── PushNotificationIOS.xcscheme ├── RCTConvert+Notification.h ├── RCTConvert+Notification.m ├── RNCPushNotificationIOS.h └── RNCPushNotificationIOS.m ├── js ├── index.js └── types.js ├── package.json ├── tsconfig.json └── yarn.lock /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ["@react-native-community"] 4 | }; 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | [lints] 48 | sketchy-null-number=warn 49 | sketchy-null-mixed=warn 50 | sketchy-number=warn 51 | untyped-type-import=warn 52 | nonstrict-import=warn 53 | deprecated-type=warn 54 | unsafe-getters-setters=warn 55 | unnecessary-invariant=warn 56 | signature-verification-failure=warn 57 | deprecated-utility=error 58 | 59 | [strict] 60 | deprecated-type 61 | nonstrict-import 62 | sketchy-null 63 | unclear-type 64 | unsafe-getters-setters 65 | untyped-import 66 | untyped-type-import 67 | 68 | [version] 69 | ^0.137.0 70 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: push 3 | 4 | jobs: 5 | lint: 6 | runs-on: ubuntu-latest 7 | strategy: 8 | matrix: 9 | node-version: [16] 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v1 13 | with: 14 | node-version: ${{ matrix.node-version }} 15 | - name: Get yarn cache 16 | id: yarn-cache 17 | run: echo "::set-output name=dir::$(yarn cache dir)" 18 | - uses: actions/cache@v2 19 | with: 20 | path: ${{ steps.yarn-cache.outputs.dir }} 21 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 22 | - name: Install Dependencies 23 | run: yarn 24 | - name: ESLint Checks 25 | run: yarn lint 26 | tsc: 27 | runs-on: ubuntu-latest 28 | strategy: 29 | matrix: 30 | node-version: [16] 31 | steps: 32 | - uses: actions/checkout@v2 33 | - uses: actions/setup-node@v1 34 | with: 35 | node-version: ${{ matrix.node-version }} 36 | - name: Get yarn cache 37 | id: yarn-cache 38 | run: echo "::set-output name=dir::$(yarn cache dir)" 39 | - uses: actions/cache@v2 40 | with: 41 | path: ${{ steps.yarn-cache.outputs.dir }} 42 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 43 | - name: Install Dependencies 44 | run: yarn 45 | - name: TypeScript type check 46 | run: yarn test:tsc 47 | flow: 48 | runs-on: ubuntu-latest 49 | strategy: 50 | matrix: 51 | node-version: [16] 52 | steps: 53 | - uses: actions/checkout@v2 54 | - uses: actions/setup-node@v1 55 | with: 56 | node-version: ${{ matrix.node-version }} 57 | - name: Get yarn cache 58 | id: yarn-cache 59 | run: echo "::set-output name=dir::$(yarn cache dir)" 60 | - uses: actions/cache@v2 61 | with: 62 | path: ${{ steps.yarn-cache.outputs.dir }} 63 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 64 | - name: Install Dependencies 65 | run: yarn 66 | - name: TypeScript type check 67 | run: yarn test:flow 68 | ios: 69 | runs-on: macos-latest 70 | strategy: 71 | matrix: 72 | node-version: [16] 73 | steps: 74 | - uses: actions/checkout@v2 75 | - uses: actions/setup-node@v1 76 | with: 77 | node-version: ${{ matrix.node-version }} 78 | - name: Get yarn cache 79 | id: yarn-cache 80 | run: echo "::set-output name=dir::$(yarn cache dir)" 81 | - uses: actions/cache@v2 82 | with: 83 | path: ${{ steps.yarn-cache.outputs.dir }} 84 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 85 | - name: Install Dependencies 86 | run: yarn 87 | - name: Install Podfiles 88 | run: cd example && npx pod-install 89 | - name: Build example app 90 | run: yarn ios 91 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # OSX 3 | # 4 | .DS_Store 5 | 6 | # node.js 7 | # 8 | node_modules/ 9 | npm-debug.log 10 | yarn-error.log 11 | 12 | 13 | # Xcode 14 | # 15 | build/ 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | xcuserdata 25 | *.xccheckout 26 | *.moved-aside 27 | DerivedData 28 | *.hmap 29 | *.ipa 30 | *.xcuserstate 31 | project.xcworkspace 32 | 33 | 34 | # Android/IntelliJ 35 | # 36 | build/ 37 | .idea 38 | .gradle 39 | local.properties 40 | *.iml 41 | 42 | # BUCK 43 | buck-out/ 44 | \.buckd/ 45 | *.keystore 46 | 47 | # Editor config 48 | .vscode 49 | 50 | # eslintcache 51 | .eslintcache 52 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.yarnclean: -------------------------------------------------------------------------------- 1 | # test directories 2 | __tests__ 3 | test 4 | tests 5 | powered-test 6 | 7 | # asset directories 8 | docs 9 | doc 10 | website 11 | images 12 | 13 | # examples 14 | example 15 | examples 16 | 17 | # code coverage directories 18 | coverage 19 | .nyc_output 20 | 21 | # build scripts 22 | Makefile 23 | Gulpfile.js 24 | Gruntfile.js 25 | 26 | # configs 27 | appveyor.yml 28 | circle.yml 29 | codeship-services.yml 30 | codeship-steps.yml 31 | wercker.yml 32 | .tern-project 33 | .gitattributes 34 | .editorconfig 35 | .*ignore 36 | .eslintrc 37 | .jshintrc 38 | .flowconfig 39 | .documentup.json 40 | .yarn-metadata.json 41 | .travis.yml 42 | 43 | # misc 44 | *.md 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 react-native-community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE.% -------------------------------------------------------------------------------- /RNCPushNotificationIOS.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(File.dirname(__FILE__), "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | # NPM package specification 7 | 8 | s.name = 'RNCPushNotificationIOS' 9 | s.version = package['version'] 10 | s.summary = package['description'] 11 | s.description = package['description'] 12 | s.license = package['license'] 13 | s.author = package['author'] 14 | s.homepage = package['homepage'] 15 | 16 | s.source = { :git => "https://github.com/react-native-community/push-notification-ios", :tag => "v#{s.version}" } 17 | s.source_files = "ios/*.{h,m}" 18 | 19 | s.platform = :ios, "10.0" 20 | 21 | s.dependency "React-Core" 22 | 23 | end 24 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.reactnativecommunity.pushnotificationios", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.reactnativecommunity.pushnotificationios", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | project.ext.react = [ 76 | entryFile: "index.js" 77 | ] 78 | 79 | apply from: "../../node_modules/react-native/react.gradle" 80 | 81 | /** 82 | * Set this to true to create two separate APKs instead of one: 83 | * - An APK that only works on ARM devices 84 | * - An APK that only works on x86 devices 85 | * The advantage is the size of the APK is reduced by about 4MB. 86 | * Upload all the APKs to the Play Store and people will download 87 | * the correct one based on the CPU architecture of their device. 88 | */ 89 | def enableSeparateBuildPerCPUArchitecture = false 90 | 91 | /** 92 | * Run Proguard to shrink the Java bytecode in release builds. 93 | */ 94 | def enableProguardInReleaseBuilds = false 95 | 96 | android { 97 | compileSdkVersion rootProject.ext.compileSdkVersion 98 | buildToolsVersion rootProject.ext.buildToolsVersion 99 | 100 | defaultConfig { 101 | applicationId "com.reactnativecommunity.pushnotificationios" 102 | minSdkVersion rootProject.ext.minSdkVersion 103 | targetSdkVersion rootProject.ext.targetSdkVersion 104 | versionCode 1 105 | versionName "1.0" 106 | } 107 | splits { 108 | abi { 109 | reset() 110 | enable enableSeparateBuildPerCPUArchitecture 111 | universalApk false // If true, also generate a universal APK 112 | include "armeabi-v7a", "x86", "arm64-v8a" 113 | } 114 | } 115 | buildTypes { 116 | release { 117 | minifyEnabled enableProguardInReleaseBuilds 118 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 119 | } 120 | } 121 | // applicationVariants are e.g. debug, release 122 | applicationVariants.all { variant -> 123 | variant.outputs.each { output -> 124 | // For each separate APK per architecture, set a unique version code as described here: 125 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 126 | def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3] 127 | def abi = output.getFilter(OutputFile.ABI) 128 | if (abi != null) { // null for the universal-debug, universal-release variants 129 | output.versionCodeOverride = 130 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 131 | } 132 | } 133 | } 134 | } 135 | 136 | dependencies { 137 | implementation fileTree(dir: "libs", include: ["*.jar"]) 138 | implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" 139 | implementation "com.facebook.react:react-native:+" // From node_modules 140 | } 141 | 142 | // Run this once to be able to run the application with BUCK 143 | // puts all compile dependencies into folder libs for BUCK to use 144 | task copyDownloadableDepsToLibs(type: Copy) { 145 | from configurations.compile 146 | into 'libs' 147 | } 148 | -------------------------------------------------------------------------------- /android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/pushnotificationios/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.reactnativecommunity.pushnotificationios; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "PushNotificationIOS"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/pushnotificationios/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactnativecommunity.pushnotificationios; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | 29 | @Override 30 | protected String getJSMainModuleName() { 31 | return "index"; 32 | } 33 | }; 34 | 35 | @Override 36 | public ReactNativeHost getReactNativeHost() { 37 | return mReactNativeHost; 38 | } 39 | 40 | @Override 41 | public void onCreate() { 42 | super.onCreate(); 43 | SoLoader.init(this, /* native exopackage */ false); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PushNotificationIOS 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "28.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 28 8 | targetSdkVersion = 27 9 | supportLibVersion = "28.0.0" 10 | } 11 | repositories { 12 | google() 13 | mavenCentral() 14 | } 15 | dependencies { 16 | classpath 'com.android.tools.build:gradle:3.2.1' 17 | 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | google() 27 | mavenCentral() 28 | maven { 29 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 30 | url "$rootDir/../node_modules/react-native/android" 31 | } 32 | } 33 | } 34 | 35 | 36 | task wrapper(type: Wrapper) { 37 | gradleVersion = '4.7' 38 | distributionUrl = distributionUrl.replace("bin", "all") 39 | } 40 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/react-native-push-notification/ios/84a3dd1aa4174ded90d1fb62e48b0278f3f488f9/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'PushNotificationIOS' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | plugins: [ 4 | [ 5 | 'module-resolver', 6 | { 7 | alias: { 8 | '@react-native-community/push-notification-ios': './js', 9 | }, 10 | cwd: 'babelrc', 11 | }, 12 | ], 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /docs/manual-linking.md: -------------------------------------------------------------------------------- 1 | # Manual linking 2 | 3 | - Add the `.xcodeproj` to your project 4 | ``` 5 | node_modules/@react-native-community/push-notification-ios/ios/PushNotificationIOS.xcodeproj 6 | ``` 7 | 8 | - Add the following to `Link Binary With Libraries` phase 9 | ``` 10 | libRNCPushNotificationIOS.a 11 | ``` 12 | 13 | More info on manual linking, [here](https://reactnative.dev/docs/linking-libraries-ios). 14 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @flow 6 | */ 7 | 8 | import * as React from 'react'; 9 | import {useState, useEffect} from 'react'; 10 | import { 11 | Alert, 12 | StyleSheet, 13 | Text, 14 | Pressable, 15 | ScrollView, 16 | View, 17 | DeviceEventEmitter, 18 | SafeAreaView, 19 | } from 'react-native'; 20 | import PushNotificationIOS from '../js'; 21 | 22 | type ButtonProps = {| 23 | onPress: () => void | Promise, 24 | label: string, 25 | |}; 26 | 27 | const Button: React.StatelessFunctionalComponent = ({ 28 | onPress, 29 | label, 30 | }) => { 31 | return ( 32 | /** $FlowFixMe */ 33 | 34 | {label} 35 | 36 | ); 37 | }; 38 | 39 | export const App = (): React.Node => { 40 | const [permissions, setPermissions] = useState({}); 41 | 42 | useEffect(() => { 43 | PushNotificationIOS.addEventListener('register', onRegistered); 44 | PushNotificationIOS.addEventListener( 45 | 'registrationError', 46 | onRegistrationError, 47 | ); 48 | PushNotificationIOS.addEventListener('notification', onRemoteNotification); 49 | PushNotificationIOS.addEventListener( 50 | 'localNotification', 51 | onLocalNotification, 52 | ); 53 | 54 | PushNotificationIOS.requestPermissions({ 55 | alert: true, 56 | badge: true, 57 | sound: true, 58 | critical: true, 59 | }).then( 60 | (data) => { 61 | console.log('PushNotificationIOS.requestPermissions', data); 62 | }, 63 | (data) => { 64 | console.log('PushNotificationIOS.requestPermissions failed', data); 65 | }, 66 | ); 67 | 68 | return () => { 69 | PushNotificationIOS.removeEventListener('register'); 70 | PushNotificationIOS.removeEventListener('registrationError'); 71 | PushNotificationIOS.removeEventListener('notification'); 72 | PushNotificationIOS.removeEventListener('localNotification'); 73 | }; 74 | // eslint-disable-next-line react-hooks/exhaustive-deps 75 | }, []); 76 | 77 | const sendNotification = () => { 78 | DeviceEventEmitter.emit('remoteNotificationReceived', { 79 | remote: true, 80 | aps: { 81 | alert: {title: 'title', subtitle: 'subtitle', body: 'body'}, 82 | badge: 1, 83 | sound: 'default', 84 | category: 'REACT_NATIVE', 85 | 'content-available': 1, 86 | 'mutable-content': 1, 87 | }, 88 | }); 89 | }; 90 | 91 | const sendSilentNotification = () => { 92 | DeviceEventEmitter.emit('remoteNotificationReceived', { 93 | remote: true, 94 | aps: { 95 | category: 'REACT_NATIVE', 96 | 'content-available': 1, 97 | }, 98 | }); 99 | }; 100 | 101 | const sendLocalNotification = () => { 102 | PushNotificationIOS.presentLocalNotification({ 103 | alertTitle: 'Sample Title', 104 | alertBody: 'Sample local notification', 105 | applicationIconBadgeNumber: 1, 106 | }); 107 | }; 108 | 109 | const sendLocalNotificationWithSound = () => { 110 | PushNotificationIOS.addNotificationRequest({ 111 | id: 'notificationWithSound', 112 | title: 'Sample Title', 113 | subtitle: 'Sample Subtitle', 114 | body: 'Sample local notification with custom sound', 115 | sound: 'customSound.wav', 116 | badge: 1, 117 | }); 118 | }; 119 | 120 | const scheduleLocalNotification = () => { 121 | PushNotificationIOS.scheduleLocalNotification({ 122 | alertBody: 'Test Local Notification', 123 | fireDate: new Date(new Date().valueOf() + 2000).toISOString(), 124 | }); 125 | }; 126 | 127 | const addNotificationRequest = () => { 128 | PushNotificationIOS.addNotificationRequest({ 129 | id: 'test', 130 | title: 'title', 131 | subtitle: 'subtitle', 132 | body: 'body', 133 | category: 'test', 134 | threadId: 'thread-id', 135 | fireDate: new Date(new Date().valueOf() + 2000), 136 | repeats: true, 137 | userInfo: { 138 | image: 'https://www.github.com/Naturalclar.png', 139 | }, 140 | }); 141 | }; 142 | 143 | const addCriticalNotificationRequest = () => { 144 | PushNotificationIOS.addNotificationRequest({ 145 | id: 'critical', 146 | title: 'Critical Alert', 147 | subtitle: 'subtitle', 148 | body: 'This is a critical alert', 149 | category: 'test', 150 | threadId: 'thread-id', 151 | isCritical: true, 152 | fireDate: new Date(new Date().valueOf() + 2000), 153 | repeats: true, 154 | }); 155 | }; 156 | 157 | const addMultipleRequests = () => { 158 | PushNotificationIOS.addNotificationRequest({ 159 | id: 'test-1', 160 | title: 'First', 161 | subtitle: 'subtitle', 162 | body: 'First Notification out of 3', 163 | category: 'test', 164 | threadId: 'thread-id', 165 | fireDate: new Date(new Date().valueOf() + 10000), 166 | repeats: true, 167 | }); 168 | 169 | PushNotificationIOS.addNotificationRequest({ 170 | id: 'test-2', 171 | title: 'Second', 172 | subtitle: 'subtitle', 173 | body: 'Second Notification out of 3', 174 | category: 'test', 175 | threadId: 'thread-id', 176 | fireDate: new Date(new Date().valueOf() + 12000), 177 | repeats: true, 178 | }); 179 | 180 | PushNotificationIOS.addNotificationRequest({ 181 | id: 'test-3', 182 | title: 'Third', 183 | subtitle: 'subtitle', 184 | body: 'Third Notification out of 3', 185 | category: 'test', 186 | threadId: 'thread-id', 187 | fireDate: new Date(new Date().valueOf() + 14000), 188 | repeats: true, 189 | }); 190 | }; 191 | 192 | const getPendingNotificationRequests = () => { 193 | PushNotificationIOS.getPendingNotificationRequests((requests) => { 194 | Alert.alert('Push Notification Received', JSON.stringify(requests), [ 195 | { 196 | text: 'Dismiss', 197 | onPress: null, 198 | }, 199 | ]); 200 | }); 201 | }; 202 | 203 | const setNotificationCategories = async () => { 204 | PushNotificationIOS.setNotificationCategories([ 205 | { 206 | id: 'test', 207 | actions: [ 208 | {id: 'open', title: 'Open', options: {foreground: true}}, 209 | { 210 | id: 'ignore', 211 | title: 'Desruptive', 212 | options: {foreground: true, destructive: true}, 213 | }, 214 | { 215 | id: 'text', 216 | title: 'Text Input', 217 | options: {foreground: true}, 218 | textInput: {buttonTitle: 'Send'}, 219 | }, 220 | ], 221 | }, 222 | ]); 223 | Alert.alert( 224 | 'setNotificationCategories', 225 | `Set notification category complete`, 226 | [ 227 | { 228 | text: 'Dismiss', 229 | onPress: null, 230 | }, 231 | ], 232 | ); 233 | }; 234 | 235 | const removeAllPendingNotificationRequests = () => { 236 | PushNotificationIOS.removeAllPendingNotificationRequests(); 237 | }; 238 | 239 | const removePendingNotificationRequests = () => { 240 | PushNotificationIOS.removePendingNotificationRequests(['test-1', 'test-2']); 241 | }; 242 | 243 | const onRegistered = (deviceToken) => { 244 | Alert.alert('Registered For Remote Push', `Device Token: ${deviceToken}`, [ 245 | { 246 | text: 'Dismiss', 247 | onPress: null, 248 | }, 249 | ]); 250 | }; 251 | 252 | const onRegistrationError = (error) => { 253 | Alert.alert( 254 | 'Failed To Register For Remote Push', 255 | `Error (${error.code}): ${error.message}`, 256 | [ 257 | { 258 | text: 'Dismiss', 259 | onPress: null, 260 | }, 261 | ], 262 | ); 263 | }; 264 | 265 | const onRemoteNotification = (notification) => { 266 | const isClicked = notification.getData().userInteraction === 1; 267 | 268 | const result = ` 269 | Title: ${notification.getTitle()};\n 270 | Subtitle: ${notification.getSubtitle()};\n 271 | Message: ${notification.getMessage()};\n 272 | badge: ${notification.getBadgeCount()};\n 273 | sound: ${notification.getSound()};\n 274 | category: ${notification.getCategory()};\n 275 | content-available: ${notification.getContentAvailable()};\n 276 | Notification is clicked: ${String(isClicked)}.`; 277 | 278 | if (notification.getTitle() == undefined) { 279 | Alert.alert('Silent push notification Received', result, [ 280 | { 281 | text: 'Send local push', 282 | onPress: sendLocalNotification, 283 | }, 284 | ]); 285 | } else { 286 | Alert.alert('Push Notification Received', result, [ 287 | { 288 | text: 'Dismiss', 289 | onPress: null, 290 | }, 291 | ]); 292 | } 293 | notification.finish('UIBackgroundFetchResultNoData') 294 | }; 295 | 296 | const onLocalNotification = (notification) => { 297 | const isClicked = notification.getData().userInteraction === 1; 298 | 299 | Alert.alert( 300 | 'Local Notification Received', 301 | `Alert title: ${notification.getTitle()}, 302 | Alert subtitle: ${notification.getSubtitle()}, 303 | Alert message: ${notification.getMessage()}, 304 | Badge: ${notification.getBadgeCount()}, 305 | Sound: ${notification.getSound()}, 306 | Thread Id: ${notification.getThreadID()}, 307 | Action Id: ${notification.getActionIdentifier()}, 308 | User Text: ${notification.getUserText()}, 309 | Notification is clicked: ${String(isClicked)}.`, 310 | [ 311 | { 312 | text: 'Dismiss', 313 | onPress: null, 314 | }, 315 | ], 316 | ); 317 | }; 318 | 319 | const showPermissions = () => { 320 | PushNotificationIOS.checkPermissions((permissions) => { 321 | setPermissions({permissions}); 322 | }); 323 | }; 324 | 325 | return ( 326 | 327 | 328 | 329 |