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
eb8f865a
Commit
eb8f865a
authored
Jun 09, 2016
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass token instead of object in refresh callback
parent
fd8f4a4c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
README.md
README.md
+6
-8
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
...rc/main/java/com/evollu/react/fcm/FIRMessagingModule.java
+5
-8
ios/RNFIRMesssaging.m
ios/RNFIRMesssaging.m
+1
-3
No files found.
README.md
View file @
eb8f865a
...
...
@@ -89,15 +89,13 @@ in AppDelegate.m add
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
[FIRApp configure]; <-- add this line
[FIRApp configure]; <-- add this line
}
//add this method
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
[[NSNotificationCenter defaultCenter] postNotificationName: FCMNotificationReceived
object:self
userInfo:notification];
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler {
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification];
handler(UIBackgroundFetchResultNoData);
}
```
...
...
@@ -120,8 +118,8 @@ In [firebase console](https://console.firebase.google.com/), you can get `google
this
.
notificationUnsubscribe
=
FCM
.
on
(
'
notification
'
,
(
notif
)
=>
{
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
});
this
.
refreshUnsubscribe
=
FCM
.
on
(
'
refresh
'
,
(
data
)
=>
{
console
.
log
(
data
.
token
)
this
.
refreshUnsubscribe
=
FCM
.
on
(
'
refresh
Token
'
,
(
token
)
=>
{
console
.
log
(
token
)
// fcm token may not be available on first load, catch it here
});
}
...
...
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
View file @
eb8f865a
...
...
@@ -96,10 +96,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
if
(
getReactApplicationContext
().
hasActiveCatalystInstance
())
{
String
token
=
intent
.
getStringExtra
(
"token"
);
WritableMap
params
=
Arguments
.
createMap
();
params
.
putString
(
"token"
,
token
);
sendEvent
(
"FCMTokenRefreshed"
,
params
);
sendEvent
(
"FCMTokenRefreshed"
,
token
);
abortBroadcast
();
}
}
...
...
ios/RNFIRMesssaging.m
View file @
eb8f865a
...
...
@@ -86,9 +86,7 @@ RCT_REMAP_METHOD(getFCMToken,
-
(
void
)
onTokenRefresh
{
NSDictionary
*
info
=
@{
@"token"
:
[[
FIRInstanceID
instanceID
]
token
]};
[
_bridge
.
eventDispatcher
sendDeviceEventWithName
:
@"FCMTokenRefreshed"
body:
info
];
[
_bridge
.
eventDispatcher
sendDeviceEventWithName
:
@"FCMTokenRefreshed"
body
:[[
FIRInstanceID
instanceID
]
token
]];
}
RCT_EXPORT_METHOD
(
requestPermissions
)
...
...
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