Skip to content

Instantly share code, notes, and snippets.

@hyperh
Last active May 20, 2016 06:32
Show Gist options
  • Save hyperh/995b6fab59a6e91f3ce05b4706b53bf6 to your computer and use it in GitHub Desktop.
Save hyperh/995b6fab59a6e91f3ce05b4706b53bf6 to your computer and use it in GitHub Desktop.
Setting up react-native-push-notification
import React from 'react-native';
import PushNotification from 'react-native-push-notification';
export default function () {
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister(data) {
Meteor.call('notifications.set.pushToken', {data}, err => {
if (err) { alert(`notifications.set.pushToken: ${err.reason}`); }
});
},
// (required) Called when a remote or local notification is opened or received
onNotification(notification) {
alert(`onNotification ${React.Platform.OS}`);
},
// 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,
/**
* IOS ONLY: (optional) default: true
* - Specified if permissions will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment