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
07664a60
Commit
07664a60
authored
Nov 23, 2016
by
d4vidi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling notification post (local notif style)
parent
c28a2c9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
android/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java
...ivenotifications/core/notification/IPushNotification.java
+6
-0
android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
...tivenotifications/core/notification/PushNotification.java
+17
-2
No files found.
android/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java
View file @
07664a60
...
...
@@ -18,5 +18,11 @@ public interface IPushNotification {
*/
void
onOpened
();
/**
* Handle a request to post this notification.
* @return ID to optionally use for notification deletion.
*/
int
onPostRequest
();
PushNotificationProps
asProps
();
}
android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
View file @
07664a60
...
...
@@ -68,15 +68,20 @@ public class PushNotification implements IPushNotification {
PushNotificationsDrawer
.
get
(
mContext
).
onNotificationOpened
();
}
@Override
public
int
onPostRequest
()
{
return
postNotification
();
}
@Override
public
PushNotificationProps
asProps
()
{
return
mNotificationProps
.
copy
();
}
protected
void
postNotification
()
{
protected
int
postNotification
()
{
final
PendingIntent
pendingIntent
=
getCTAPendingIntent
();
final
Notification
notification
=
buildNotification
(
pendingIntent
);
postNotification
((
int
)
System
.
currentTimeMillis
(),
notification
);
return
postNotification
(
notification
);
}
protected
void
digestNotification
()
{
...
...
@@ -141,11 +146,21 @@ public class PushNotification implements IPushNotification {
.
setAutoCancel
(
true
);
}
protected
int
postNotification
(
Notification
notification
)
{
int
id
=
createNotificationId
(
notification
);
postNotification
(
id
,
notification
);
return
id
;
}
protected
void
postNotification
(
int
id
,
Notification
notification
)
{
final
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
id
,
notification
);
}
protected
int
createNotificationId
(
Notification
notification
)
{
return
(
int
)
System
.
currentTimeMillis
();
}
protected
ReactContext
getRunningReactContext
()
{
final
ReactNativeHost
rnHost
=
((
ReactApplication
)
mContext
.
getApplicationContext
()).
getReactNativeHost
();
if
(!
rnHost
.
hasInstance
())
{
...
...
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