Created
December 27, 2020 17:03
-
-
Save ShanikaNishadhi/402dddb7b7c52e97513ebbe1fef25337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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