Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-notifications
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
冷佳娟
react-native-notifications
Commits
e819748f
Commit
e819748f
authored
Jul 07, 2019
by
yogevbd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
5c2c649d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
23 deletions
+25
-23
RNNotifications/RNCommandsHandler.m
RNNotifications/RNCommandsHandler.m
+0
-1
RNNotifications/RNEventEmitter.h
RNNotifications/RNEventEmitter.h
+7
-7
RNNotifications/RNNotificationEventHandler.h
RNNotifications/RNNotificationEventHandler.h
+3
-0
RNNotifications/RNNotificationEventHandler.m
RNNotifications/RNNotificationEventHandler.m
+10
-1
RNNotifications/RNNotifications.m
RNNotifications/RNNotifications.m
+5
-14
No files found.
RNNotifications/RNCommandsHandler.m
View file @
e819748f
...
...
@@ -11,7 +11,6 @@
-
(
instancetype
)
initWithStore
:(
RNNotificationsStore
*
)
store
{
self
=
[
super
init
];
_store
=
store
;
return
self
;
}
...
...
RNNotifications/RNEventEmitter.h
View file @
e819748f
#import "RCTEventEmitter.h"
static
NSString
*
const
RNRegistered
=
@"RNN
otificationsRegistered"
;
static
NSString
*
const
RNRegistrationFailed
=
@"RNN
otificationsRegistrationFailed"
;
static
NSString
*
const
RNPushKitRegistered
=
@"RNP
ushKitRegistered"
;
static
NSString
*
const
RNNotificationReceivedForeground
=
@"RNN
otificationReceivedForeground"
;
static
NSString
*
const
RNNotificationReceivedBackground
=
@"RNN
otificationReceivedBackground"
;
static
NSString
*
const
RNNotificationOpened
=
@"RNN
otificationOpened"
;
static
NSString
*
const
RNActionTriggered
=
@"RNN
otificationActionTriggered"
;
static
NSString
*
const
RNRegistered
=
@"n
otificationsRegistered"
;
static
NSString
*
const
RNRegistrationFailed
=
@"n
otificationsRegistrationFailed"
;
static
NSString
*
const
RNPushKitRegistered
=
@"p
ushKitRegistered"
;
static
NSString
*
const
RNNotificationReceivedForeground
=
@"n
otificationReceivedForeground"
;
static
NSString
*
const
RNNotificationReceivedBackground
=
@"n
otificationReceivedBackground"
;
static
NSString
*
const
RNNotificationOpened
=
@"n
otificationOpened"
;
static
NSString
*
const
RNActionTriggered
=
@"n
otificationActionTriggered"
;
@interface
RNEventEmitter
:
RCTEventEmitter
...
...
RNNotifications/RNNotificationEventHandler.h
View file @
e819748f
...
...
@@ -6,6 +6,9 @@
-
(
instancetype
)
initWithStore
:(
RNNotificationsStore
*
)
store
;
-
(
void
)
didRegisterForRemoteNotificationsWithDeviceToken
:(
id
)
deviceToken
;
-
(
void
)
didFailToRegisterForRemoteNotificationsWithError
:(
NSError
*
)
error
;
-
(
void
)
didReceiveForegroundPayload
:(
NSDictionary
*
)
payload
;
-
(
void
)
didOpenNotificationPayload
:(
NSDictionary
*
)
payload
;
-
(
void
)
handleActionWithIdentifier
:(
NSString
*
)
identifier
forPayload
:(
NSDictionary
*
)
payload
withResponse
:(
NSString
*
)
response
completionHandler
:(
void
(
^
)())
completionHandler
;
...
...
RNNotifications/RNNotificationEventHandler.m
View file @
e819748f
#import "RNNotificationEventHandler.h"
#import "RNEventEmitter.h"
#import "RNUtils.h"
@implementation
RNNotificationEventHandler
{
RNNotificationsStore
*
_store
;
...
...
@@ -8,10 +9,18 @@
-
(
instancetype
)
initWithStore
:(
RNNotificationsStore
*
)
store
{
self
=
[
super
init
];
_store
=
store
;
return
self
;
}
-
(
void
)
didRegisterForRemoteNotificationsWithDeviceToken
:(
id
)
deviceToken
{
NSString
*
tokenRepresentation
=
[
deviceToken
isKindOfClass
:[
NSString
class
]]
?
deviceToken
:
[
RNUtils
deviceTokenToString
:
deviceToken
];
[
RNEventEmitter
sendEvent
:
RNRegistered
body
:@{
@"deviceToken"
:
tokenRepresentation
}];
}
-
(
void
)
didFailToRegisterForRemoteNotificationsWithError
:(
NSError
*
)
error
{
[
RNEventEmitter
sendEvent
:
RNRegistrationFailed
body
:@{
@"code"
:
[
NSNumber
numberWithInteger
:
error
.
code
],
@"domain"
:
error
.
domain
,
@"localizedDescription"
:
error
.
localizedDescription
}];
}
-
(
void
)
didReceiveForegroundPayload
:(
NSDictionary
*
)
payload
{
[
RNEventEmitter
sendEvent
:
RNNotificationReceivedForeground
body
:
payload
];
}
...
...
RNNotifications/RNNotifications.m
View file @
e819748f
...
...
@@ -2,20 +2,12 @@
#import <UIKit/UIKit.h>
#import <PushKit/PushKit.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import "RNNotifications.h"
#import <React/RCTConvert.h>
#import <React/RCTUtils.h>
#import <UserNotifications/UserNotifications.h>
#import "RNEventEmitter.h"
#import "RNNotificationCenterListener.h"
#import "RNUtils.h"
NSString
*
const
RNNotificationCreateAction
=
@"CREATE"
;
NSString
*
const
RNNotificationClearAction
=
@"CLEAR"
;
@implementation
RNNotifications
{
RNNotificationCenterListener
*
_notificationCenterListener
;
RNNotificationEventHandler
*
_notificationEventHandler
;
}
+
(
instancetype
)
sharedInstance
{
...
...
@@ -29,17 +21,16 @@ NSString* const RNNotificationClearAction = @"CLEAR";
}
-
(
void
)
initialize
{
RNNotificationEventHandler
*
notificationEventHandler
=
[
RNNotificationEventHandler
new
];
_notificationCenterListener
=
[[
RNNotificationCenterListener
alloc
]
initWithNotificationEventHandler
:
notificationEventHandler
];
_
notificationEventHandler
=
[
RNNotificationEventHandler
new
];
_notificationCenterListener
=
[[
RNNotificationCenterListener
alloc
]
initWithNotificationEventHandler
:
_
notificationEventHandler
];
}
-
(
void
)
didRegisterForRemoteNotificationsWithDeviceToken
:(
id
)
deviceToken
{
NSString
*
tokenRepresentation
=
[
deviceToken
isKindOfClass
:[
NSString
class
]]
?
deviceToken
:
[
RNUtils
deviceTokenToString
:
deviceToken
];
[
RNEventEmitter
sendEvent
:
RNRegistered
body
:@{
@"deviceToken"
:
tokenRepresentation
}];
[
_notificationEventHandler
didRegisterForRemoteNotificationsWithDeviceToken
:
deviceToken
];
}
-
(
void
)
didFailToRegisterForRemoteNotificationsWithError
:(
NSError
*
)
error
{
[
RNEventEmitter
sendEvent
:
RNRegistrationFailed
body
:@{
@"code"
:
[
NSNumber
numberWithInteger
:
error
.
code
],
@"domain"
:
error
.
domain
,
@"localizedDescription"
:
error
.
localizedDescription
}
];
[
_notificationEventHandler
didFailToRegisterForRemoteNotificationsWithError
:
error
];
}
-
(
void
)
setBadgeForNotification
:(
NSDictionary
*
)
notification
{
...
...
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