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
37492496
Commit
37492496
authored
Apr 13, 2016
by
Lidan Hifi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix badge handling, added category to local notification
parent
cfded35f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
RNNotifications/RNNotifications.m
RNNotifications/RNNotifications.m
+7
-3
notification.ios.js
notification.ios.js
+1
-2
test/notification.ios.spec.js
test/notification.ios.spec.js
+2
-2
No files found.
RNNotifications/RNNotifications.m
View file @
37492496
...
@@ -54,10 +54,13 @@ static NSString* username;
...
@@ -54,10 +54,13 @@ static NSString* username;
UIApplicationState
state
=
[
UIApplication
sharedApplication
].
applicationState
;
UIApplicationState
state
=
[
UIApplication
sharedApplication
].
applicationState
;
if
(
state
==
UIApplicationStateActive
)
{
if
(
state
==
UIApplicationStateActive
)
{
// Notification received foreground
[
self
didReceiveNotificationOnForegroundState
:
notification
];
[
self
didReceiveNotificationOnForegroundState
:
notification
];
}
else
if
(
state
==
UIApplicationStateInactive
)
{
}
else
if
(
state
==
UIApplicationStateInactive
)
{
// Notification opened
[
self
didNotificationOpen
:
notification
];
[
self
didNotificationOpen
:
notification
];
}
else
{
}
else
{
// Notification received background
[
self
didReceiveNotificationOnBackgroundState
:
notification
];
[
self
didReceiveNotificationOnBackgroundState
:
notification
];
}
}
}
}
...
@@ -135,10 +138,10 @@ static NSString* username;
...
@@ -135,10 +138,10 @@ static NSString* username;
UILocalNotification
*
note
=
[[
UILocalNotification
alloc
]
init
];
UILocalNotification
*
note
=
[[
UILocalNotification
alloc
]
init
];
note
.
alertTitle
=
[
alert
objectForKey
:
@"title"
];
note
.
alertTitle
=
[
alert
objectForKey
:
@"title"
];
note
.
alertBody
=
[
alert
objectForKey
:
@"body"
];
note
.
alertBody
=
[
alert
objectForKey
:
@"body"
];
note
.
userInfo
=
managedAps
;
note
.
userInfo
=
notification
;
note
.
soundName
=
[
managedAps
objectForKey
:
@"sound"
];
note
.
soundName
=
[
managedAps
objectForKey
:
@"sound"
];
note
.
category
=
[
managedAps
objectForKey
:
@"category"
];
NSLog
(
@"Presenting local notification..."
);
[[
UIApplication
sharedApplication
]
presentLocalNotificationNow
:
note
];
[[
UIApplication
sharedApplication
]
presentLocalNotificationNow
:
note
];
// Serialize it and store so we can delete it later
// Serialize it and store so we can delete it later
...
@@ -157,12 +160,13 @@ static NSString* username;
...
@@ -157,12 +160,13 @@ static NSString* username;
NSData
*
data
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
notificationKey
];
NSData
*
data
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
notificationKey
];
if
(
data
)
{
if
(
data
)
{
UILocalNotification
*
notification
=
[
NSKeyedUnarchiver
unarchiveObjectWithData
:
data
];
UILocalNotification
*
notification
=
[
NSKeyedUnarchiver
unarchiveObjectWithData
:
data
];
NSLog
(
@"Remove local notification: %@"
,
notificationKey
);
// delete the notification
// delete the notification
[[
UIApplication
sharedApplication
]
cancelLocalNotification
:
notification
];
[[
UIApplication
sharedApplication
]
cancelLocalNotification
:
notification
];
[[
NSUserDefaults
standardUserDefaults
]
removeObjectForKey
:
notificationKey
];
[[
NSUserDefaults
standardUserDefaults
]
removeObjectForKey
:
notificationKey
];
NSLog
(
@"Local notification removed: %@"
,
notificationKey
);
return
;
return
;
}
}
}
}
...
...
notification.ios.js
View file @
37492496
...
@@ -14,12 +14,11 @@ export default class IOSNotification {
...
@@ -14,12 +14,11 @@ export default class IOSNotification {
notification
.
aps
[
"
content-available
"
]
===
1
&&
notification
.
aps
[
"
content-available
"
]
===
1
&&
!
notification
.
aps
.
alert
&&
!
notification
.
aps
.
alert
&&
!
notification
.
aps
.
sound
&&
!
notification
.
aps
.
sound
&&
!
notification
.
aps
.
badge
&&
notification
.
managedAps
)
{
notification
.
managedAps
)
{
// managed notification
// managed notification
this
.
_alert
=
notification
.
managedAps
.
alert
;
this
.
_alert
=
notification
.
managedAps
.
alert
;
this
.
_sound
=
notification
.
managedAps
.
sound
;
this
.
_sound
=
notification
.
managedAps
.
sound
;
this
.
_badge
=
notification
.
managedA
ps
.
badge
;
this
.
_badge
=
notification
.
a
ps
.
badge
;
this
.
_category
=
notification
.
managedAps
.
category
;
this
.
_category
=
notification
.
managedAps
.
category
;
this
.
_type
=
"
managed
"
;
this
.
_type
=
"
managed
"
;
}
else
if
(
}
else
if
(
...
...
test/notification.ios.spec.js
View file @
37492496
...
@@ -74,7 +74,8 @@ describe("iOS Notification Object", () => {
...
@@ -74,7 +74,8 @@ describe("iOS Notification Object", () => {
describe
(
"
for a managed iOS push notification (silent notification, with managedAps key and content-available = 1)
"
,
()
=>
{
describe
(
"
for a managed iOS push notification (silent notification, with managedAps key and content-available = 1)
"
,
()
=>
{
let
managedNativeNotification
=
{
let
managedNativeNotification
=
{
aps
:
{
aps
:
{
"
content-available
"
:
1
"
content-available
"
:
1
,
badge
:
someBadgeCount
},
},
managedAps
:
{
managedAps
:
{
action
:
"
CREATE
"
,
action
:
"
CREATE
"
,
...
@@ -83,7 +84,6 @@ describe("iOS Notification Object", () => {
...
@@ -83,7 +84,6 @@ describe("iOS Notification Object", () => {
title
:
"
some title
"
,
title
:
"
some title
"
,
body
:
"
some body
"
body
:
"
some body
"
},
},
badge
:
someBadgeCount
,
sound
:
someSound
,
sound
:
someSound
,
category
:
someCategory
category
:
someCategory
},
},
...
...
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