Created
November 29, 2017 04:49
-
-
Save crimson-med/904be53aa37cf552b480366cb0192e42 to your computer and use it in GitHub Desktop.
Handle actions through fcm push
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
OPTManager(){ | |
AsyncStorage.setItem('myProfile_OTP', "true").catch(erop =>{ | |
console.error(erop) | |
}); | |
DeviceEventEmitter.emit('refreshOTP', "true") | |
} | |
componentWillMount{ | |
FCM.getInitialNotification().then(notif => { | |
if(notif.click_action == "OTP RENEW"){ | |
this.OPTManager(); | |
} | |
} | |
sendRemote(notif) { | |
if (notif.click_action == "OTP RENEW"){ | |
this.OPTManager(); | |
} | |
if(notif.fcm && notif.fcm.body) { | |
/* Create local notification for showing in a foreground */ | |
//console.warn("notif") | |
if (notif.fcm.body=="OTP RENEW"){ | |
//console.warn ("plop") | |
this.OPTManager(); | |
} | |
FCM.presentLocalNotification({ | |
body: notif.fcm.body, | |
priority: "high", | |
title: notif.fcm.title, | |
sound: "default", | |
"large_icon": "ic_launcher",// Android only | |
icon: "ic_launcher2", | |
"show_in_foreground" :true, /* notification when app is in foreground (local & remote)*/ | |
vibrate: 300, /* Android only default: 300, no vibration if you pass null*/ | |
"lights": true, // Android only, LED blinking (default false) | |
status: notif.status | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment