Commit ba4368b4 authored by Libin Lu's avatar Libin Lu

add schedule notification

parent f22edb07
......@@ -28,6 +28,14 @@ export default class App extends Component {
}
}
componentDidMount(){
FCM.getInitialNotification().then(notif => {
this.setState({
initNotif: notif
})
});
}
showLocalNotification() {
FCM.presentLocalNotification({
vibrate: 500,
......@@ -39,6 +47,19 @@ export default class App extends Component {
});
}
scheduleLocalNotification() {
FCM.scheduleLocalNotification({
id: 'testnotif',
fire_date: new Date().getTime()+5000,
vibrate: 500,
title: 'Hello',
body: 'Test Scheduled Notification',
priority: "high",
show_in_foreground: true,
picture: 'https://firebase.google.com/_static/af7ae4b3fc/images/firebase/lockup.png'
});
}
render() {
let { token, tokenCopyFeedback } = this.state;
......@@ -51,6 +72,11 @@ export default class App extends Component {
Welcome to Simple Fcm Client!
</Text>
<Text>
Init notif: {JSON.stringify(this.state.initNotif)}
</Text>
<Text selectable={true} onPress={() => this.setClipboardContent(this.state.token)} style={styles.instructions}>
Token: {this.state.token}
</Text>
......@@ -74,6 +100,10 @@ export default class App extends Component {
<TouchableOpacity onPress={() => this.showLocalNotification()} style={styles.button}>
<Text style={styles.buttonText}>Send Local Notification</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.scheduleLocalNotification()} style={styles.button}>
<Text style={styles.buttonText}>Schedule Notification in 5s</Text>
</TouchableOpacity>
</View>
);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment