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
4567efcb
Commit
4567efcb
authored
Jul 13, 2017
by
Ran
Committed by
GitHub
Jul 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #87 from wix/isRegisteredForRemoteNotifications
iOS API - Is registered for remote notifications
parents
43a4c895
cb2ec057
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
13 deletions
+44
-13
RNNotifications/RNNotifications.m
RNNotifications/RNNotifications.m
+13
-0
index.ios.js
index.ios.js
+4
-0
test/index.ios.spec.js
test/index.ios.spec.js
+27
-13
No files found.
RNNotifications/RNNotifications.m
View file @
4567efcb
...
...
@@ -549,4 +549,17 @@ RCT_EXPORT_METHOD(cancelAllLocalNotifications)
[
RCTSharedApplication
()
cancelAllLocalNotifications
];
}
RCT_EXPORT_METHOD
(
isRegisteredForRemoteNotifications
:
(
RCTPromiseResolveBlock
)
resolve
reject
:
(
RCTPromiseRejectBlock
)
reject
)
{
BOOL
ans
;
if
(
TARGET_IPHONE_SIMULATOR
)
{
ans
=
[[[
UIApplication
sharedApplication
]
currentUserNotificationSettings
]
types
]
!=
0
;
}
else
{
ans
=
[[
UIApplication
sharedApplication
]
isRegisteredForRemoteNotifications
];
}
resolve
(
@
(
ans
));
}
@end
index.ios.js
View file @
4567efcb
...
...
@@ -203,4 +203,8 @@ export default class NotificationsIOS {
static
cancelAllLocalNotifications
()
{
NativeRNNotifications
.
cancelAllLocalNotifications
();
}
static
isRegisteredForRemoteNotifications
()
{
return
NativeRNNotifications
.
isRegisteredForRemoteNotifications
();
}
}
test/index.ios.spec.js
View file @
4567efcb
...
...
@@ -17,18 +17,19 @@ describe("NotificationsIOS", () => {
/*eslint-disable indent*/
let
deviceAddEventListener
,
deviceRemoveEventListener
,
nativeAppAddEventListener
,
nativeAppRemoveEventListener
,
nativeRequestPermissionsWithCategories
,
nativeAbandonPermissions
,
nativeRegisterPushKit
,
nativeBackgroundTimeRemaining
,
nativeConsumeBackgroundQueue
,
nativeLocalNotification
,
nativeCancelLocalNotification
,
nativeCancelAllLocalNotifications
,
nativeSetBadgesCount
;
deviceRemoveEventListener
,
nativeAppAddEventListener
,
nativeAppRemoveEventListener
,
nativeRequestPermissionsWithCategories
,
nativeAbandonPermissions
,
nativeRegisterPushKit
,
nativeBackgroundTimeRemaining
,
nativeConsumeBackgroundQueue
,
nativeLocalNotification
,
nativeCancelLocalNotification
,
nativeCancelAllLocalNotifications
,
nativeSetBadgesCount
,
nativeIsRegisteredForRemoteNotifications
;
let
NotificationsIOS
,
NotificationAction
,
NotificationCategory
;
let
someHandler
=
()
=>
{};
...
...
@@ -49,6 +50,7 @@ describe("NotificationsIOS", () => {
nativeCancelLocalNotification
=
sinon
.
spy
();
nativeCancelAllLocalNotifications
=
sinon
.
spy
();
nativeSetBadgesCount
=
sinon
.
spy
();
nativeIsRegisteredForRemoteNotifications
=
sinon
.
spy
();
let
libUnderTest
=
proxyquire
(
"
../index.ios
"
,
{
"
uuid
"
:
{
...
...
@@ -65,7 +67,8 @@ describe("NotificationsIOS", () => {
localNotification
:
nativeLocalNotification
,
cancelLocalNotification
:
nativeCancelLocalNotification
,
cancelAllLocalNotifications
:
nativeCancelAllLocalNotifications
,
setBadgesCount
:
nativeSetBadgesCount
setBadgesCount
:
nativeSetBadgesCount
,
isRegisteredForRemoteNotifications
:
nativeIsRegisteredForRemoteNotifications
}
},
NativeAppEventEmitter
:
{
...
...
@@ -104,6 +107,7 @@ describe("NotificationsIOS", () => {
nativeLocalNotification
.
reset
();
nativeCancelLocalNotification
.
reset
();
nativeCancelAllLocalNotifications
.
reset
();
nativeIsRegisteredForRemoteNotifications
.
reset
();
});
after
(()
=>
{
...
...
@@ -119,6 +123,7 @@ describe("NotificationsIOS", () => {
nativeLocalNotification
=
null
;
nativeCancelLocalNotification
=
null
;
nativeCancelAllLocalNotifications
=
null
;
nativeIsRegisteredForRemoteNotifications
=
null
;
NotificationsIOS
=
null
;
NotificationAction
=
null
;
...
...
@@ -295,4 +300,13 @@ describe("NotificationsIOS", () => {
expect
(
nativeCancelAllLocalNotifications
).
to
.
have
.
been
.
calledWith
();
});
});
describe
(
"
Is registered for remote notifications
"
,
()
=>
{
it
(
"
should call native is registered for remote notifications
"
,
()
=>
{
NotificationsIOS
.
isRegisteredForRemoteNotifications
();
expect
(
nativeIsRegisteredForRemoteNotifications
).
to
.
have
.
been
.
calledWith
();
});
});
});
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