Last active
May 20, 2016 06:32
-
-
Save hyperh/995b6fab59a6e91f3ce05b4706b53bf6 to your computer and use it in GitHub Desktop.
Setting up react-native-push-notification
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
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