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
c63281c8
Commit
c63281c8
authored
Feb 08, 2018
by
Libin Lu
Committed by
GitHub
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
broadcast refresh token
parent
4d5254fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
android/src/main/java/com/evollu/react/fcm/InstanceIdService.java
...src/main/java/com/evollu/react/fcm/InstanceIdService.java
+31
-2
No files found.
android/src/main/java/com/evollu/react/fcm/InstanceIdService.java
View file @
c63281c8
...
...
@@ -2,9 +2,14 @@ package com.evollu.react.fcm;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.support.v4.content.LocalBroadcastManager
;
import
android.util.Log
;
import
com.facebook.react.ReactApplication
;
import
com.facebook.react.ReactInstanceManager
;
import
com.facebook.react.bridge.ReactContext
;
import
com.google.firebase.iid.FirebaseInstanceId
;
import
com.google.firebase.iid.FirebaseInstanceIdService
;
...
...
@@ -25,11 +30,35 @@ public class InstanceIdService extends FirebaseInstanceIdService {
Log
.
d
(
TAG
,
"Refreshed token: "
+
refreshedToken
);
// Broadcast refreshed token
Intent
i
=
new
Intent
(
"com.evollu.react.fcm.FCMRefreshToken"
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"token"
,
refreshedToken
);
i
.
putExtras
(
bundle
);
LocalBroadcastManager
.
getInstance
(
getApplicationContext
()).
sendBroadcast
(
i
);
final
Intent
message
=
i
;
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
)
{
LocalBroadcastManager
.
getInstance
(
getApplicationContext
()).
sendBroadcast
(
message
);
}
else
{
// Otherwise wait for construction, then send the notification
mReactInstanceManager
.
addReactInstanceEventListener
(
new
ReactInstanceManager
.
ReactInstanceEventListener
()
{
public
void
onReactContextInitialized
(
ReactContext
context
)
{
LocalBroadcastManager
.
getInstance
(
getApplicationContext
()).
sendBroadcast
(
message
);
}
});
if
(!
mReactInstanceManager
.
hasStartedCreatingInitialContext
())
{
// Construct it in the background
mReactInstanceManager
.
createReactContextInBackground
();
}
}
}
});
}
}
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