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
4e4018b4
Commit
4e4018b4
authored
Jan 29, 2017
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use constants
parent
0c7584e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
index.js
index.js
+11
-4
ios/RNFIRMesssaging.m
ios/RNFIRMesssaging.m
+4
-4
No files found.
index.js
View file @
4e4018b4
...
...
@@ -16,6 +16,13 @@ export const WillPresentNotificationResult = {
None
:
'
UNNotificationPresentationOptionNone
'
}
export
const
NotificationType
=
{
Remote
:
'
remote_notification
'
,
NotificationResponse
:
'
notification_response
'
,
WillPresent
:
'
will_present_notification
'
,
Local
:
'
local_notification
'
}
const
RNFIRMessaging
=
NativeModules
.
RNFIRMessaging
;
const
FCM
=
{};
...
...
@@ -87,18 +94,18 @@ function finish(result){
}
if
(
!
this
.
_finishCalled
&&
this
.
_completionHandlerId
){
this
.
_finishCalled
=
true
;
switch
(
this
.
notification_event_t
ype
){
case
'
remote_notification
'
:
switch
(
this
.
_notificationT
ype
){
case
NotificationType
.
Remote
:
result
=
result
||
RemoteNotificationResult
.
NoData
;
if
(
!
Object
.
values
(
RemoteNotificationResult
).
includes
(
result
)){
throw
new
Error
(
`Invalid RemoteNotificationResult, use import {RemoteNotificationResult} from 'react-native-fcm' to avoid typo`
);
}
RNFIRMessaging
.
finishRemoteNotification
(
this
.
_completionHandlerId
,
result
);
return
;
case
'
notification_response
'
:
case
NotificationType
.
NotificationResponse
:
RNFIRMessaging
.
finishNotificationResponse
(
this
.
_completionHandlerId
);
return
;
case
'
will_present_notification
'
:
case
NotificationType
.
WillPresent
:
result
=
result
||
(
this
.
show_in_foreground
?
WillPresentNotificationResult
.
All
:
WillPresentNotificationResult
.
None
);
if
(
!
Object
.
values
(
WillPresentNotificationResult
).
includes
(
result
)){
throw
new
Error
(
`Invalid WillPresentNotificationResult, make sure you use import {WillPresentNotificationResult} from 'react-native-fcm' to avoid typo`
);
...
...
ios/RNFIRMesssaging.m
View file @
4e4018b4
...
...
@@ -144,21 +144,21 @@ RCT_EXPORT_MODULE()
+
(
void
)
didReceiveRemoteNotification
:(
nonnull
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
RCTRemoteNotificationCallback
)
completionHandler
{
NSMutableDictionary
*
data
=
[[
NSMutableDictionary
alloc
]
initWithDictionary
:
userInfo
];
[
data
setValue
:
@"remote_notification"
forKey
:
@"
notification_event_t
ype"
];
[
data
setValue
:
@"remote_notification"
forKey
:
@"
_notificationT
ype"
];
[
data
setValue
:
@
(
RCTSharedApplication
().
applicationState
==
UIApplicationStateInactive
)
forKey
:
@"opened_from_tray"
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
@{
@"data"
:
data
,
@"completionHandler"
:
completionHandler
}];
}
+
(
void
)
didReceiveLocalNotification
:(
UILocalNotification
*
)
notification
{
NSMutableDictionary
*
data
=
[[
NSMutableDictionary
alloc
]
initWithDictionary
:
notification
.
userInfo
];
[
data
setValue
:
@"local_notification"
forKey
:
@"
notification_event_t
ype"
];
[
data
setValue
:
@"local_notification"
forKey
:
@"
_notificationT
ype"
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
data
];
}
+
(
void
)
didReceiveNotificationResponse
:(
UNNotificationResponse
*
)
response
withCompletionHandler
:(
RCTNotificationResponseCallback
)
completionHandler
{
NSMutableDictionary
*
data
=
[[
NSMutableDictionary
alloc
]
initWithDictionary
:
response
.
notification
.
request
.
content
.
userInfo
];
[
data
setValue
:
@"notification_response"
forKey
:
@"
notification_event_t
ype"
];
[
data
setValue
:
@"notification_response"
forKey
:
@"
_notificationT
ype"
];
[
data
setValue
:
@YES
forKey
:
@"opened_from_tray"
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
@{
@"data"
:
data
,
@"completionHandler"
:
completionHandler
}];
}
...
...
@@ -166,7 +166,7 @@ RCT_EXPORT_MODULE()
+
(
void
)
willPresentNotification
:(
UNNotification
*
)
notification
withCompletionHandler
:(
RCTWillPresentNotificationCallback
)
completionHandler
{
NSMutableDictionary
*
data
=
[[
NSMutableDictionary
alloc
]
initWithDictionary
:
notification
.
request
.
content
.
userInfo
];
[
data
setValue
:
@"will_present_notification"
forKey
:
@"
notification_event_t
ype"
];
[
data
setValue
:
@"will_present_notification"
forKey
:
@"
_notificationT
ype"
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
@{
@"data"
:
data
,
@"completionHandler"
:
completionHandler
}];
}
...
...
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