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
9856f121
Commit
9856f121
authored
Apr 24, 2017
by
Omri Bruchim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add setBadgesCount function (for iOS)
parent
e4cd4b91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
README.md
README.md
+10
-0
RNNotifications/RNNotifications.m
RNNotifications/RNNotifications.m
+5
-0
index.ios.js
index.ios.js
+4
-0
test/index.ios.spec.js
test/index.ios.spec.js
+15
-2
No files found.
README.md
View file @
9856f121
...
...
@@ -612,6 +612,16 @@ The [example app](https://github.com/wix/react-native-notifications/tree/master/
-
`minimal`
- Displays up tp 2 actions (minimal UI).
#### Set application icon badges count (iOS only)
Set to specific number:
```
javascript
NotificationsIOS
.
setBadgesCount
(
2
);
```
Clear badges icon:
```
javascript
NotificationsIOS
.
setBadgesCount
(
0
);
```
## License
The MIT License.
...
...
RNNotifications/RNNotifications.m
View file @
9856f121
...
...
@@ -476,6 +476,11 @@ RCT_EXPORT_METHOD(registerPushKit)
[
RNNotifications
registerPushKit
];
}
RCT_EXPORT_METHOD
(
setBadgesCount
:
(
int
)
count
)
{
[[
UIApplication
sharedApplication
]
setApplicationIconBadgeNumber
:
count
];
}
RCT_EXPORT_METHOD
(
backgroundTimeRemaining
:
(
RCTResponseSenderBlock
)
callback
)
{
NSTimeInterval
remainingTime
=
[
UIApplication
sharedApplication
].
backgroundTimeRemaining
;
...
...
index.ios.js
View file @
9856f121
...
...
@@ -156,6 +156,10 @@ export default class NotificationsIOS {
_actionHandlers
.
clear
();
}
static
setBadgesCount
(
count
:
number
)
{
NativeRNNotifications
.
setBadgesCount
(
count
);
}
static
registerPushKit
()
{
NativeRNNotifications
.
registerPushKit
();
}
...
...
test/index.ios.spec.js
View file @
9856f121
...
...
@@ -27,7 +27,9 @@ describe("NotificationsIOS", () => {
nativeConsumeBackgroundQueue
,
nativeLocalNotification
,
nativeCancelLocalNotification
,
nativeCancelAllLocalNotifications
;
nativeCancelAllLocalNotifications
,
nativeSetBadgesCount
;
let
NotificationsIOS
,
NotificationAction
,
NotificationCategory
;
let
someHandler
=
()
=>
{};
let
constantGuid
=
"
some-random-uuid
"
;
...
...
@@ -46,6 +48,7 @@ describe("NotificationsIOS", () => {
nativeLocalNotification
=
sinon
.
spy
();
nativeCancelLocalNotification
=
sinon
.
spy
();
nativeCancelAllLocalNotifications
=
sinon
.
spy
();
nativeSetBadgesCount
=
sinon
.
spy
();
let
libUnderTest
=
proxyquire
(
"
../index.ios
"
,
{
"
uuid
"
:
{
...
...
@@ -61,7 +64,8 @@ describe("NotificationsIOS", () => {
consumeBackgroundQueue
:
nativeConsumeBackgroundQueue
,
localNotification
:
nativeLocalNotification
,
cancelLocalNotification
:
nativeCancelLocalNotification
,
cancelAllLocalNotifications
:
nativeCancelAllLocalNotifications
cancelAllLocalNotifications
:
nativeCancelAllLocalNotifications
,
setBadgesCount
:
nativeSetBadgesCount
}
},
NativeAppEventEmitter
:
{
...
...
@@ -208,6 +212,15 @@ describe("NotificationsIOS", () => {
expect
(
nativeAppRemoveEventListener
).
to
.
have
.
been
.
calledOnce
;
});
});
describe
(
"
set badges count
"
,
()
=>
{
it
(
"
should call native setBadgesCount
"
,
()
=>
{
NotificationsIOS
.
setBadgesCount
(
44
);
expect
(
nativeSetBadgesCount
).
to
.
have
.
been
.
calledWith
(
44
);
});
});
});
describe
(
"
register push kit for background notifications
"
,
function
()
{
...
...
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