Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SmartCloudAppNotificationService
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baijinqiu
SmartCloudAppNotificationService
Commits
22566ddf
Commit
22566ddf
authored
May 20, 2020
by
baijinqiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现通知、点击通知跳到指定路由、app图标显示数值的功能
parent
2169fce0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
.idea/workspace.xml
+1
-2
src/android/onservice/HandleService.java
+7
-1
src/android/onservice/NotificationService.java
+9
-1
No files found.
.idea/workspace.xml
View file @
22566ddf
...
...
@@ -3,8 +3,6 @@
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"2e775c3f-ff13-4f54-ba20-3e0eeadc9822"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/plugin.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/plugin.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/android/ONService.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/android/ONService.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/android/onservice/HandleService.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/android/onservice/HandleService.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/android/onservice/NotificationService.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/android/onservice/NotificationService.java"
afterDir=
"false"
/>
</list>
...
...
@@ -58,6 +56,7 @@
<workItem
from=
"1589766857083"
duration=
"2925000"
/>
<workItem
from=
"1589791590396"
duration=
"2832000"
/>
<workItem
from=
"1589860449552"
duration=
"2327000"
/>
<workItem
from=
"1589938957473"
duration=
"5615000"
/>
</task>
<servers
/>
</component>
...
...
src/android/onservice/HandleService.java
View file @
22566ddf
...
...
@@ -22,7 +22,7 @@ public class HandleService extends IntentService {
protected
void
onHandleIntent
(
@Nullable
Intent
intent
)
{
// Log.e(TAG, "onHandleIntent: userId "+ intent.getStringExtra("userId"));
// Log.e(TAG, "onHandleIntent: schoolId "+ intent.getStringExtra("schoolId"));
Log
.
e
(
TAG
,
"onHandleIntent: object "
+
intent
.
getStringExtra
(
"object"
));
Log
.
e
(
TAG
,
"onHandleIntent: object "
+
intent
.
getStringExtra
(
"object"
));
// NotificationService.webView.loadUrl(intent.getStringExtra("url"));
NotificationService
.
cordovaPlugin
.
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
...
...
@@ -35,6 +35,12 @@ public class HandleService extends IntentService {
@Override
public
int
onStartCommand
(
@Nullable
Intent
intent
,
int
flags
,
int
startId
)
{
NotificationService
.
cordovaPlugin
.
getActivity
().
startActivity
(
new
Intent
(
NotificationService
.
cordovaPlugin
.
getContext
(),
MainActivity
.
class
));
NotificationService
.
cordovaPlugin
.
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationService
.
webView
.
loadUrl
(
"javascript:cordova.plugins.notification.badge.decrease(1)"
);
}
});
// Log.e(TAG, "onStartCommand: userId "+ intent.getStringExtra("userId"));
// Log.e(TAG, "onStartCommand: schoolId "+ intent.getStringExtra("schoolId"));
// Log.e(TAG, "onStartCommand: url " + intent.getStringExtra("url"));
...
...
src/android/onservice/NotificationService.java
View file @
22566ddf
...
...
@@ -176,10 +176,18 @@ public class NotificationService extends Service {
.
setContentTitle
(
content
.
messageTitle
)
.
setContentIntent
(
pendingIntent
)
.
setContentText
(
content
.
body
)
.
setNumber
(
2
)
// .setAutoCancel(true)
.
build
();
notification
.
flags
=
Notification
.
FLAG_AUTO_CANCEL
;
//
notification.flags = Notification.FLAG_AUTO_CANCEL;
// 是否允许清除通知
// notification.flags |= Notification.FLAG_NO_CLEAR;
cordovaPlugin
.
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:cordova.plugins.notification.badge.increase(1)"
);
}
});
manager
.
notify
(
Integer
.
parseInt
(
content
.
id
),
notification
);
}
...
...
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