Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

push notification react native

/**
 * @format
 */

import PushNotificationIOS from '@react-native-community/push-notification-ios';
import { AppRegistry } from 'react-native';
import PushNotification from 'react-native-push-notification';
import App from './App';
import { name as appName } from './app.json';

// Must be outside of any component LifeCycle (such as `componentDidMount`).
PushNotification.configure({
  // (optional) Called when Token is generated (iOS and Android)
  onRegister: function (token) {
    console.log('TOKEN:', token);
  },

  // (required) Called when a remote is received or opened, or local notification is opened
  onNotification: function (notification) {
    console.log('NOTIFICATION:', notification);

    // process the notification
    // (required) Called when a remote is received or opened, or local notification is opened
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  },

  // (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android)
  onAction: function (notification) {
    console.log('ACTION:', notification.action);
    console.log('NOTIFICATION:', notification);
    // process the action
  },

  // (optional) Called when the user fails to register for remote notifications. Typically occurs when APNS is having issues, or the device is a simulator. (iOS)
  onRegistrationError: function (err) {
    console.error(err.message, err);
  },

  // IOS ONLY (optional): default: all - Permissions to register.
  permissions: {
    alert: true,
    badge: true,
    sound: true,
  },

  // Should the initial notification be popped automatically
  // default: true

  popInitialNotification: true,

  /**
   * (optional) default: true
   * - Specified if permissions (ios) and token (android and ios) will requested or not,
   * - if not, you must call PushNotificationsHandler.requestPermissions() later
   * - if you are not using remote notification or do not have Firebase installed, use this:
   *     requestPermissions: Platform.OS === 'ios'
   */

  requestPermissions: true,
});

AppRegistry.registerComponent(appName, () => App);
Comment

notification react native

yarn add react-native-push-notification
Comment

react native notifications error

// Added by Youtube : CodingBite
buildscript {
    ext {
        //...
        kotlinVersion = "1.3.72"    //added for react native notifications
    }
    dependencies {
        //...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"        //added for react native notifications
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: dynamodb json to regular json 
Javascript :: how to display json data in html 
Javascript :: .classList 
Javascript :: javascript weakmap 
Javascript :: sequelize attributes exclude all 
Javascript :: How to compare two different date formats in javascript 
Javascript :: javascript document 
Javascript :: create and save xml file in javascript 
Javascript :: queryinterface select 
Javascript :: sorting the object 
Javascript :: splice method js 
Javascript :: javascript easy resize for screen size 
Javascript :: timezone in react js 
Javascript :: Computed Property 
Javascript :: calendar picker react js 
Javascript :: template strings in js 
Javascript :: event handler 
Javascript :: how to make a bigint in javascript 
Javascript :: react-bootstrap sidebar menu 
Javascript :: javascript for...in loop 
Javascript :: find vs filter 
Javascript :: javascript date timezone 
Javascript :: how to use a debugger 
Javascript :: Set an onclick function with a parameter for an element 
Javascript :: angular flex layout 
Javascript :: conver all array to object 
Javascript :: javascript problems 
Javascript :: how to pass functions as a props in react js 
Javascript :: get the last element of array javascript 
Javascript :: E.g query mongodb - node 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =