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
fbe27081
Commit
fbe27081
authored
Apr 16, 2018
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show last notification
parent
e340c109
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
Examples/firebase-migration/app/App.js
Examples/firebase-migration/app/App.js
+18
-1
Examples/firebase-migration/app/Listeners.js
Examples/firebase-migration/app/Listeners.js
+1
-9
Examples/firebase-migration/ios/SimpleFcmClient.xcodeproj/xcshareddata/xcschemes/SimpleFcmClient.xcscheme
...xcodeproj/xcshareddata/xcschemes/SimpleFcmClient.xcscheme
+0
-2
No files found.
Examples/firebase-migration/app/App.js
View file @
fbe27081
...
@@ -73,6 +73,16 @@ class MainPage extends Component {
...
@@ -73,6 +73,16 @@ class MainPage extends Component {
// topic example
// topic example
firebase
.
messaging
().
subscribeToTopic
(
'
sometopic
'
);
firebase
.
messaging
().
subscribeToTopic
(
'
sometopic
'
);
firebase
.
messaging
().
unsubscribeFromTopic
(
'
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
this
.
setState
({
offlineNotif
:
JSON
.
parse
(
data
)
});
AsyncStorage
.
removeItem
(
'
lastNotification
'
);
}
})
}
}
componentWillUnmount
(){
componentWillUnmount
(){
...
@@ -192,7 +202,14 @@ class MainPage extends Component {
...
@@ -192,7 +202,14 @@ class MainPage extends Component {
Init notif:
Init notif:
</Text>
</Text>
<Text>
<Text>
{JSON.stringify(this.state.initNotif && this.state.initNotif.data)}
{JSON.stringify(this.state.initNotif)}
</Text>
<Text style={styles.instructions}>
Notif when app was closed:
</Text>
<Text>
{JSON.stringify(this.state.offlineNotif)}
</Text>
</Text>
<Text style={styles.instructions}>
<Text style={styles.instructions}>
...
...
Examples/firebase-migration/app/Listeners.js
View file @
fbe27081
...
@@ -2,14 +2,6 @@ import { Platform, AsyncStorage, AppState } from 'react-native';
...
@@ -2,14 +2,6 @@ import { Platform, AsyncStorage, AppState } from 'react-native';
import
firebase
from
'
react-native-firebase
'
;
import
firebase
from
'
react-native-firebase
'
;
AsyncStorage
.
getItem
(
'
lastNotification
'
).
then
(
data
=>
{
if
(
data
){
// if notification arrives when app is killed, it should still be logged here
console
.
log
(
'
last notification
'
,
JSON
.
parse
(
data
));
AsyncStorage
.
removeItem
(
'
lastNotification
'
);
}
})
function
displayNotificationFromCustomData
(
message
:
RemoteMessage
){
function
displayNotificationFromCustomData
(
message
:
RemoteMessage
){
if
(
message
.
data
&&
message
.
data
.
custom_notification
){
if
(
message
.
data
&&
message
.
data
.
custom_notification
){
let
notification
=
new
firebase
.
notifications
.
Notification
();
let
notification
=
new
firebase
.
notifications
.
Notification
();
...
@@ -24,7 +16,7 @@ function displayNotificationFromCustomData(message: RemoteMessage){
...
@@ -24,7 +16,7 @@ function displayNotificationFromCustomData(message: RemoteMessage){
}
}
export
function
registerKilledListener
(
message
:
RemoteMessage
){
export
function
registerKilledListener
(
message
:
RemoteMessage
){
AsyncStorage
.
setItem
(
'
lastNotification
'
,
JSON
.
stringify
(
message
));
AsyncStorage
.
setItem
(
'
lastNotification
'
,
JSON
.
stringify
(
message
.
data
));
displayNotificationFromCustomData
();
displayNotificationFromCustomData
();
}
}
...
...
Examples/firebase-migration/ios/SimpleFcmClient.xcodeproj/xcshareddata/xcschemes/SimpleFcmClient.xcscheme
View file @
fbe27081
...
@@ -54,7 +54,6 @@
...
@@ -54,7 +54,6 @@
buildConfiguration =
"Debug"
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
language =
""
shouldUseLaunchSchemeArgsEnv =
"YES"
>
shouldUseLaunchSchemeArgsEnv =
"YES"
>
<Testables>
<Testables>
<TestableReference
<TestableReference
...
@@ -84,7 +83,6 @@
...
@@ -84,7 +83,6 @@
buildConfiguration =
"Debug"
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
language =
""
launchStyle =
"0"
launchStyle =
"0"
useCustomWorkingDirectory =
"NO"
useCustomWorkingDirectory =
"NO"
ignoresPersistentStateOnLaunch =
"NO"
ignoresPersistentStateOnLaunch =
"NO"
...
...
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