Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
a051ca64
Commit
a051ca64
authored
May 30, 2019
by
Sébastiaan Versteeg
Browse files
Merge branch 'feat/open-notification-text' into 'master'
Show notification on app open Closes #93 See merge request
!270
parents
50ed3223
a1887e07
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/app.js
View file @
a051ca64
...
...
@@ -48,26 +48,7 @@ class Main extends Component {
this
.
onTokenRefreshListener
=
firebase
.
messaging
().
onTokenRefresh
(()
=>
{
store
.
dispatch
(
register
());
});
this
.
notificationListener
=
firebase
.
notifications
().
onNotification
((
notification
)
=>
{
let
buttons
;
if
(
notification
.
data
.
url
)
{
buttons
=
[
{
text
:
this
.
props
.
t
(
'
Dismiss
'
)
},
{
text
:
this
.
props
.
t
(
'
Open
'
),
onPress
:
()
=>
store
.
dispatch
(
deepLinkingActions
.
deepLink
(
notification
.
data
.
url
,
false
),
),
},
];
}
else
{
buttons
=
[
{
text
:
'
OK
'
},
];
}
Alert
.
alert
(
notification
.
title
,
notification
.
body
,
buttons
);
});
this
.
notificationListener
=
firebase
.
notifications
().
onNotification
(
this
.
showNotification
);
this
.
notificationOpenedListener
=
firebase
.
notifications
()
.
onNotificationOpened
(
this
.
handleOpenNotification
);
...
...
@@ -92,6 +73,31 @@ class Main extends Component {
}
};
showNotification
=
(
notification
)
=>
{
let
buttons
;
if
(
notification
.
data
.
url
)
{
buttons
=
[
{
text
:
this
.
props
.
t
(
'
Dismiss
'
)
},
{
text
:
this
.
props
.
t
(
'
Open
'
),
onPress
:
()
=>
store
.
dispatch
(
deepLinkingActions
.
deepLink
(
notification
.
data
.
url
,
false
),
),
},
];
}
else
{
buttons
=
[
{
text
:
'
OK
'
},
];
}
if
(
notification
.
body
!==
undefined
)
{
Alert
.
alert
(
notification
.
title
,
notification
.
body
,
buttons
);
}
else
if
(
notification
.
data
.
body
!==
undefined
)
{
Alert
.
alert
(
notification
.
data
.
title
,
notification
.
data
.
body
,
buttons
);
}
};
handleOpenURL
=
(
event
)
=>
{
store
.
dispatch
(
deepLinkingActions
.
deepLink
(
event
.
url
));
};
...
...
@@ -101,6 +107,8 @@ class Main extends Component {
const
notification
=
notificationOpen
.
notification
;
if
(
notification
.
data
.
url
)
{
store
.
dispatch
(
deepLinkingActions
.
deepLink
(
notification
.
data
.
url
,
false
));
}
else
{
this
.
showNotification
(
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