Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-fcm
Commits
e340c109
Commit
e340c109
authored
Apr 15, 2018
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle headless
parent
468f7bcb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
Examples/firebase-migration/app/Listeners.js
Examples/firebase-migration/app/Listeners.js
+15
-10
No files found.
Examples/firebase-migration/app/Listeners.js
View file @
e340c109
...
@@ -10,8 +10,22 @@ AsyncStorage.getItem('lastNotification').then(data=>{
...
@@ -10,8 +10,22 @@ AsyncStorage.getItem('lastNotification').then(data=>{
}
}
})
})
function
displayNotificationFromCustomData
(
message
:
RemoteMessage
){
if
(
message
.
data
&&
message
.
data
.
custom_notification
){
let
notification
=
new
firebase
.
notifications
.
Notification
();
notification
=
notification
.
setNotificationId
(
new
Date
().
valueOf
().
toString
())
.
setTitle
(
message
.
title
)
.
setBody
(
message
.
body
)
.
setData
(
message
.
data
)
.
setSound
(
"
bell.mp3
"
)
notification
.
android
.
setChannelId
(
"
test-channel
"
)
firebase
.
notifications
().
displayNotification
(
notification
);
}
}
export
function
registerKilledListener
(
message
:
RemoteMessage
){
export
function
registerKilledListener
(
message
:
RemoteMessage
){
AsyncStorage
.
setItem
(
'
lastNotification
'
,
JSON
.
stringify
(
message
));
AsyncStorage
.
setItem
(
'
lastNotification
'
,
JSON
.
stringify
(
message
));
displayNotificationFromCustomData
();
}
}
// these callback will be triggered only when app is foreground or background
// these callback will be triggered only when app is foreground or background
...
@@ -37,16 +51,7 @@ export function registerAppListener(navigation){
...
@@ -37,16 +51,7 @@ export function registerAppListener(navigation){
});
});
this
.
messageListener
=
firebase
.
messaging
().
onMessage
((
message
:
RemoteMessage
)
=>
{
this
.
messageListener
=
firebase
.
messaging
().
onMessage
((
message
:
RemoteMessage
)
=>
{
if
(
message
.
data
&&
message
.
data
.
custom_notification
){
displayNotificationFromCustomData
();
let
notification
=
new
firebase
.
notifications
.
Notification
();
notification
=
notification
.
setNotificationId
(
new
Date
().
valueOf
().
toString
())
.
setTitle
(
message
.
title
)
.
setBody
(
message
.
body
)
.
setData
(
message
.
data
)
.
setSound
(
"
bell.mp3
"
)
notification
.
android
.
setChannelId
(
"
test-channel
"
)
firebase
.
notifications
().
displayNotification
(
notification
);
}
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment