Skip to content

Instantly share code, notes, and snippets.

@ShanikaNishadhi
Created December 27, 2020 17:03
Show Gist options
  • Save ShanikaNishadhi/402dddb7b7c52e97513ebbe1fef25337 to your computer and use it in GitHub Desktop.
Save ShanikaNishadhi/402dddb7b7c52e97513ebbe1fef25337 to your computer and use it in GitHub Desktop.
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import PushNotification from 'react-native-push-notification';
import { Platform } from 'react-native';
AppRegistry.registerComponent(appName, () => App);
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);
},
// 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
*/
requestPermissions: Platform.OS === 'ios',
requestPermissions: true,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment