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
f918b56f
Commit
f918b56f
authored
Feb 24, 2018
by
Libin Lu
Committed by
GitHub
Feb 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backward compatible for addListener
parent
11a6acfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
ios/RNFIRMessaging.m
ios/RNFIRMessaging.m
+25
-11
No files found.
ios/RNFIRMessaging.m
View file @
f918b56f
...
...
@@ -217,6 +217,10 @@ RCT_MULTI_ENUM_CONVERTER(UNNotificationCategoryOptions, (@{
@end
@interface
RCTEventEmitter
()
-
(
void
)
addListener
:(
NSString
*
)
eventName
;
@end
@interface
RNFIRMessaging
()
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
notificationCallbacks
;
@end
...
...
@@ -318,6 +322,12 @@ RCT_EXPORT_MODULE();
[[
FIRMessaging
messaging
]
setDelegate
:
self
];
});
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
10
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
!
jsHandlerRegistered
){
[
self
sendPendingNotifications
];
}
});
return
self
;
}
...
...
@@ -325,20 +335,24 @@ RCT_EXPORT_MODULE();
[
super
addListener
:
eventName
];
if
([
eventName
isEqualToString
:
FCMNotificationReceived
])
{
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
jsHandlerRegistered
=
true
;
for
(
NSDictionary
*
data
in
pendingNotifications
)
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
data
];
}
[
pendingNotifications
removeAllObjects
];
});
[
self
sendPendingNotifications
];
}
}
-
(
void
)
sendPendingNotifications
{
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
jsHandlerRegistered
=
true
;
for
(
NSDictionary
*
data
in
pendingNotifications
)
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
FCMNotificationReceived
object
:
self
userInfo
:
data
];
}
[
pendingNotifications
removeAllObjects
];
});
}
RCT_EXPORT_METHOD
(
enableDirectChannel
)
{
[[
FIRMessaging
messaging
]
setShouldEstablishDirectChannel
:
@YES
];
...
...
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