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
9cc07ee2
Commit
9cc07ee2
authored
Jul 31, 2017
by
Libin Lu
Committed by
GitHub
Jul 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MessagingService.java
parent
edbf2ac3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
android/src/main/java/com/evollu/react/fcm/MessagingService.java
.../src/main/java/com/evollu/react/fcm/MessagingService.java
+28
-2
No files found.
android/src/main/java/com/evollu/react/fcm/MessagingService.java
View file @
9cc07ee2
...
...
@@ -22,7 +22,33 @@ public class MessagingService extends FirebaseMessagingService {
i
.
putExtra
(
"data"
,
remoteMessage
);
handleBadge
(
remoteMessage
);
buildLocalNotification
(
remoteMessage
);
sendOrderedBroadcast
(
i
,
null
);
// We need to run this on the main thread, as the React code assumes that is true.
// Namely, DevServerHelper constructs a Handler() without a Looper, which triggers:
// "Can't create handler inside thread that has not called Looper.prepare()"
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
());
handler
.
post
(
new
Runnable
()
{
public
void
run
()
{
// Construct and load our normal React JS code bundle
ReactInstanceManager
mReactInstanceManager
=
((
ReactApplication
)
getApplication
()).
getReactNativeHost
().
getReactInstanceManager
();
ReactContext
context
=
mReactInstanceManager
.
getCurrentReactContext
();
// If it's constructed, send a notification
if
(
context
!=
null
)
{
context
.
sendOrderedBroadcast
(
message
,
null
);
}
else
{
// Otherwise wait for construction, then send the notification
mReactInstanceManager
.
addReactInstanceEventListener
(
new
ReactInstanceManager
.
ReactInstanceEventListener
()
{
public
void
onReactContextInitialized
(
ReactContext
context
)
{
context
.
sendOrderedBroadcast
(
message
,
null
);
}
});
if
(!
mReactInstanceManager
.
hasStartedCreatingInitialContext
())
{
// Construct it in the background
mReactInstanceManager
.
createReactContextInBackground
();
}
}
}
});
}
public
void
handleBadge
(
RemoteMessage
remoteMessage
)
{
...
...
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