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
465347be
Commit
465347be
authored
Sep 21, 2016
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
combine local and remote event android
parent
aba18fd0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
8 deletions
+7
-8
android/react-native-fcm.iml
android/react-native-fcm.iml
+1
-1
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
...in/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
+0
-1
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
...rc/main/java/com/evollu/react/fcm/FIRMessagingModule.java
+2
-4
index.js
index.js
+4
-2
No files found.
android/react-native-fcm.iml
View file @
465347be
...
@@ -120,8 +120,8 @@
...
@@ -120,8 +120,8 @@
<orderEntry
type=
"library"
exported=
""
name=
"firebase-iid-9.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"firebase-iid-9.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"okio-1.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"okio-1.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"jsr305-3.0.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"jsr305-3.0.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"bolts-tasks-1.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"okhttp-3.4.1"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"okhttp-3.4.1"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"bolts-tasks-1.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"firebase-common-9.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"firebase-common-9.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"appcompat-v7-23.0.1"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"appcompat-v7-23.0.1"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"firebase-core-9.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
exported=
""
name=
"firebase-core-9.4.0"
level=
"project"
/>
...
...
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
View file @
465347be
...
@@ -159,7 +159,6 @@ public class FIRLocalMessagingHelper {
...
@@ -159,7 +159,6 @@ public class FIRLocalMessagingHelper {
Intent
intent
=
new
Intent
(
mContext
,
intentClass
);
Intent
intent
=
new
Intent
(
mContext
,
intentClass
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
putExtras
(
bundle
);
intent
.
putExtras
(
bundle
);
intent
.
putExtra
(
"localNotification"
,
true
);
intent
.
setAction
(
bundle
.
getString
(
"click_action"
));
intent
.
setAction
(
bundle
.
getString
(
"click_action"
));
int
notificationID
=
bundle
.
containsKey
(
"id"
)
?
bundle
.
getString
(
"id"
,
""
).
hashCode
()
:
(
int
)
System
.
currentTimeMillis
();
int
notificationID
=
bundle
.
containsKey
(
"id"
)
?
bundle
.
getString
(
"id"
,
""
).
hashCode
()
:
(
int
)
System
.
currentTimeMillis
();
...
...
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
View file @
465347be
...
@@ -157,7 +157,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
...
@@ -157,7 +157,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
getReactApplicationContext
().
hasActiveCatalystInstance
())
{
if
(
getReactApplicationContext
().
hasActiveCatalystInstance
())
{
sendEvent
(
"FCM
Local
NotificationReceived"
,
Arguments
.
fromBundle
(
intent
.
getExtras
()));
sendEvent
(
"FCMNotificationReceived"
,
Arguments
.
fromBundle
(
intent
.
getExtras
()));
abortBroadcast
();
abortBroadcast
();
}
}
}
}
...
@@ -206,8 +206,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
...
@@ -206,8 +206,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
@Override
@Override
public
void
onNewIntent
(
Intent
intent
){
public
void
onNewIntent
(
Intent
intent
){
Bundle
bundle
=
intent
.
getExtras
();
sendEvent
(
"FCMNotificationReceived"
,
parseIntent
(
intent
));
Boolean
isLocalNotification
=
bundle
!=
null
&&
bundle
.
getBoolean
(
"localNotification"
,
false
);
sendEvent
(
isLocalNotification
?
"FCMLocalNotificationReceived"
:
"FCMNotificationReceived"
,
parseIntent
(
intent
));
}
}
}
}
index.js
View file @
465347be
...
@@ -2,8 +2,7 @@ import {NativeModules, DeviceEventEmitter, Platform} from 'react-native';
...
@@ -2,8 +2,7 @@ import {NativeModules, DeviceEventEmitter, Platform} from 'react-native';
const
eventsMap
=
{
const
eventsMap
=
{
refreshToken
:
'
FCMTokenRefreshed
'
,
refreshToken
:
'
FCMTokenRefreshed
'
,
notification
:
'
FCMNotificationReceived
'
,
notification
:
'
FCMNotificationReceived
'
localNotification
:
'
FCMLocalNotificationReceived
'
};
};
const
RNFIRMessaging
=
NativeModules
.
RNFIRMessaging
;
const
RNFIRMessaging
=
NativeModules
.
RNFIRMessaging
;
...
@@ -57,6 +56,9 @@ FCM.getBadgeNumber = () => {
...
@@ -57,6 +56,9 @@ FCM.getBadgeNumber = () => {
FCM
.
on
=
(
event
,
callback
)
=>
{
FCM
.
on
=
(
event
,
callback
)
=>
{
const
nativeEvent
=
eventsMap
[
event
];
const
nativeEvent
=
eventsMap
[
event
];
if
(
!
nativeEvent
)
{
throw
new
Error
(
'
FCM invalid event
'
);
}
const
listener
=
DeviceEventEmitter
.
addListener
(
nativeEvent
,
callback
);
const
listener
=
DeviceEventEmitter
.
addListener
(
nativeEvent
,
callback
);
return
function
remove
()
{
return
function
remove
()
{
...
...
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