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
"...Simple.xcodeproj/xcshareddata/xcschemes/Simple.xcscheme" did not exist on "c749a3825aca0476376bad45c003dad3fc70e9b8"
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 {
...
@@ -18,5 +18,11 @@ public interface IPushNotification {
*/
*/
void
onOpened
();
void
onOpened
();
/**
* Handle a request to post this notification.
* @return ID to optionally use for notification deletion.
*/
int
onPostRequest
();
PushNotificationProps
asProps
();
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 {
...
@@ -68,15 +68,20 @@ public class PushNotification implements IPushNotification {
PushNotificationsDrawer
.
get
(
mContext
).
onNotificationOpened
();
PushNotificationsDrawer
.
get
(
mContext
).
onNotificationOpened
();
}
}
@Override
public
int
onPostRequest
()
{
return
postNotification
();
}
@Override
@Override
public
PushNotificationProps
asProps
()
{
public
PushNotificationProps
asProps
()
{
return
mNotificationProps
.
copy
();
return
mNotificationProps
.
copy
();
}
}
protected
void
postNotification
()
{
protected
int
postNotification
()
{
final
PendingIntent
pendingIntent
=
getCTAPendingIntent
();
final
PendingIntent
pendingIntent
=
getCTAPendingIntent
();
final
Notification
notification
=
buildNotification
(
pendingIntent
);
final
Notification
notification
=
buildNotification
(
pendingIntent
);
postNotification
((
int
)
System
.
currentTimeMillis
(),
notification
);
return
postNotification
(
notification
);
}
}
protected
void
digestNotification
()
{
protected
void
digestNotification
()
{
...
@@ -141,11 +146,21 @@ public class PushNotification implements IPushNotification {
...
@@ -141,11 +146,21 @@ public class PushNotification implements IPushNotification {
.
setAutoCancel
(
true
);
.
setAutoCancel
(
true
);
}
}
protected
int
postNotification
(
Notification
notification
)
{
int
id
=
createNotificationId
(
notification
);
postNotification
(
id
,
notification
);
return
id
;
}
protected
void
postNotification
(
int
id
,
Notification
notification
)
{
protected
void
postNotification
(
int
id
,
Notification
notification
)
{
final
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
final
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
id
,
notification
);
notificationManager
.
notify
(
id
,
notification
);
}
}
protected
int
createNotificationId
(
Notification
notification
)
{
return
(
int
)
System
.
currentTimeMillis
();
}
protected
ReactContext
getRunningReactContext
()
{
protected
ReactContext
getRunningReactContext
()
{
final
ReactNativeHost
rnHost
=
((
ReactApplication
)
mContext
.
getApplicationContext
()).
getReactNativeHost
();
final
ReactNativeHost
rnHost
=
((
ReactApplication
)
mContext
.
getApplicationContext
()).
getReactNativeHost
();
if
(!
rnHost
.
hasInstance
())
{
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