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
5b58a301
Commit
5b58a301
authored
Apr 26, 2018
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example
parent
6973949f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
15 deletions
+13
-15
Examples/firebase-migration/app/App.js
Examples/firebase-migration/app/App.js
+9
-11
Examples/firebase-migration/app/Listeners.js
Examples/firebase-migration/app/Listeners.js
+2
-2
Examples/firebase-migration/index.android.js
Examples/firebase-migration/index.android.js
+2
-2
No files found.
Examples/firebase-migration/app/App.js
View file @
5b58a301
...
...
@@ -48,7 +48,7 @@ class MainPage extends Component {
// Get information about the notification that was opened
const
notif
:
Notification
=
notificationOpen
.
notification
;
this
.
setState
({
initNotif
:
notif
initNotif
:
notif
.
data
})
if
(
notif
&&
notif
.
targetScreen
===
'
detail
'
){
setTimeout
(()
=>
{
...
...
@@ -75,15 +75,13 @@ class MainPage extends Component {
firebase
.
messaging
().
subscribeToTopic
(
'
sometopic
'
);
firebase
.
messaging
().
unsubscribeFromTopic
(
'
sometopic
'
);
AsyncStorage
.
getItem
(
'
lastNotification
'
).
then
(
data
=>
{
if
(
data
){
// if notification arrives when app is killed, it should still be logged here
var
offline
=
await
AsyncStorage
.
getItem
(
'
headless
'
)
if
(
offline
){
this
.
setState
({
offlineNotif
:
JSON
.
parse
(
data
)
offlineNotif
:
offline
});
AsyncStorage
.
removeItem
(
'
lastNotification
'
);
AsyncStorage
.
removeItem
(
'
headless
'
);
}
})
}
componentWillUnmount
(){
...
...
@@ -208,7 +206,7 @@ class MainPage extends Component {
Notif when app was closed:
</Text>
<Text>
{
JSON.stringify(this.state.offlineNotif)
}
{
this.state.offlineNotif
}
</Text>
<Text style={styles.instructions}>
...
...
Examples/firebase-migration/app/Listeners.js
View file @
5b58a301
...
...
@@ -16,8 +16,8 @@ function displayNotificationFromCustomData(message: RemoteMessage){
}
}
export
async
function
register
Killed
Listener
(
message
:
RemoteMessage
){
await
AsyncStorage
.
setItem
(
'
lastNotification
'
,
JSON
.
stringify
(
message
.
data
));
export
async
function
register
Headless
Listener
(
message
:
RemoteMessage
){
await
AsyncStorage
.
setItem
(
'
headless
'
,
new
Date
().
toISOString
(
));
displayNotificationFromCustomData
(
message
);
}
...
...
Examples/firebase-migration/index.android.js
View file @
5b58a301
...
...
@@ -5,7 +5,7 @@
*/
import
React
,
{
Component
}
from
'
react
'
;
import
{
register
Killed
Listener
}
from
'
./app/Listeners
'
;
import
{
register
Headless
Listener
}
from
'
./app/Listeners
'
;
import
{
AppRegistry
,
...
...
@@ -24,4 +24,4 @@ export default class SimpleFcmClient extends Component {
AppRegistry
.
registerComponent
(
'
SimpleFcmClient
'
,
()
=>
SimpleFcmClient
);
AppRegistry
.
registerHeadlessTask
(
'
RNFirebaseBackgroundMessage
'
,
()
=>
register
Killed
Listener
);
AppRegistry
.
registerHeadlessTask
(
'
RNFirebaseBackgroundMessage
'
,
()
=>
register
Headless
Listener
);
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