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
3ddddd9a
Commit
3ddddd9a
authored
Jun 30, 2020
by
TakeItEasyJQ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除schoolId
parent
ab5b9b81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
26 deletions
+18
-26
src/android/ONService.java
+15
-17
src/android/onservice/NotificationService.java
+3
-9
No files found.
src/android/ONService.java
View file @
3ddddd9a
...
@@ -19,7 +19,6 @@ import org.json.JSONException;
...
@@ -19,7 +19,6 @@ import org.json.JSONException;
import
java.util.List
;
import
java.util.List
;
/**
/**
* This class echoes a string called from JavaScript.
* This class echoes a string called from JavaScript.
*/
*/
...
@@ -68,7 +67,6 @@ public class ONService extends CordovaPlugin {
...
@@ -68,7 +67,6 @@ public class ONService extends CordovaPlugin {
Intent
intent
=
new
Intent
(
cordova
.
getActivity
(),
NotificationService
.
class
);
Intent
intent
=
new
Intent
(
cordova
.
getActivity
(),
NotificationService
.
class
);
try
{
try
{
intent
.
putExtra
(
"idCard"
,
args
.
getString
(
0
));
intent
.
putExtra
(
"idCard"
,
args
.
getString
(
0
));
intent
.
putExtra
(
"schoolId"
,
args
.
getString
(
1
));
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -92,14 +90,14 @@ public class ONService extends CordovaPlugin {
...
@@ -92,14 +90,14 @@ public class ONService extends CordovaPlugin {
// 接触activity与service的绑定(最好在退出时调用)
// 接触activity与service的绑定(最好在退出时调用)
if
(
action
.
equals
(
"unbindService"
))
{
if
(
action
.
equals
(
"unbindService"
))
{
if
(
isServiceExisted
(
NotificationService
.
class
.
getName
()))
{
cordova
.
getActivity
().
runOnUiThread
(
new
Runnable
()
{
cordova
.
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
(
)
{
if
(
isServiceExisted
(
NotificationService
.
class
.
getName
())
)
{
cordova
.
getActivity
().
unbindService
(
connection
);
cordova
.
getActivity
().
unbindService
(
connection
);
}
}
}
);
}
}
}
);
}
}
return
false
;
return
false
;
}
}
...
@@ -113,15 +111,15 @@ public class ONService extends CordovaPlugin {
...
@@ -113,15 +111,15 @@ public class ONService extends CordovaPlugin {
}
}
public
boolean
isServiceExisted
(
String
className
)
{
public
boolean
isServiceExisted
(
String
className
)
{
ActivityManager
am
=
(
ActivityManager
)
cordova
.
getActivity
().
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
ActivityManager
am
=
(
ActivityManager
)
cordova
.
getActivity
().
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
RunningServiceInfo
>
serviceList
=
am
.
getRunningServices
(
Integer
.
MAX_VALUE
);
List
<
ActivityManager
.
RunningServiceInfo
>
serviceList
=
am
.
getRunningServices
(
Integer
.
MAX_VALUE
);
int
myUid
=
android
.
os
.
Process
.
myUid
();
int
myUid
=
android
.
os
.
Process
.
myUid
();
for
(
ActivityManager
.
RunningServiceInfo
runningServiceInfo
:
serviceList
)
{
for
(
ActivityManager
.
RunningServiceInfo
runningServiceInfo
:
serviceList
)
{
if
(
runningServiceInfo
.
uid
==
myUid
&&
runningServiceInfo
.
service
.
getClassName
().
equals
(
className
))
{
if
(
runningServiceInfo
.
uid
==
myUid
&&
runningServiceInfo
.
service
.
getClassName
().
equals
(
className
))
{
return
true
;
return
true
;
}
}
}
return
false
;
}
}
return
false
;
}
}
}
src/android/onservice/NotificationService.java
View file @
3ddddd9a
...
@@ -97,7 +97,7 @@ public class NotificationService extends Service {
...
@@ -97,7 +97,7 @@ public class NotificationService extends Service {
}
}
};
};
final
String
webSocket
=
"ws://messagesrv.dev.campus.orhonedu.com:31288"
;
final
String
webSocket
=
"ws://messagesrv.dev.campus.orhonedu.com:31288"
;
final
String
api
=
"https://api.dev.campus.orhonedu.com/messagesrv/messagePush/userUnread/%s
/%s
"
;
final
String
api
=
"https://api.dev.campus.orhonedu.com/messagesrv/messagePush/userUnread/%s"
;
// ---------------------------------------------
// ---------------------------------------------
...
@@ -105,9 +105,6 @@ public class NotificationService extends Service {
...
@@ -105,9 +105,6 @@ public class NotificationService extends Service {
// 17652
// 17652
private
String
userId
;
private
String
userId
;
// 535
private
String
schoolId
;
public
static
CordovaWebView
webView
;
public
static
CordovaWebView
webView
;
public
static
CordovaInterface
cordovaPlugin
;
public
static
CordovaInterface
cordovaPlugin
;
...
@@ -156,7 +153,7 @@ public class NotificationService extends Service {
...
@@ -156,7 +153,7 @@ public class NotificationService extends Service {
};
};
clientOffline
=
new
OkHttpClient
.
Builder
().
build
();
clientOffline
=
new
OkHttpClient
.
Builder
().
build
();
Request
request
=
new
Request
.
Builder
().
url
(
String
.
format
(
api
,
userId
,
schoolId
)).
build
();
Request
request
=
new
Request
.
Builder
().
url
(
String
.
format
(
api
,
userId
)).
build
();
if
(
null
==
timer
)
{
if
(
null
==
timer
)
{
timer
=
new
Timer
();
timer
=
new
Timer
();
...
@@ -211,7 +208,6 @@ public class NotificationService extends Service {
...
@@ -211,7 +208,6 @@ public class NotificationService extends Service {
Intent
intentPending
;
Intent
intentPending
;
intentPending
=
new
Intent
(
this
,
HandleService
.
class
);
intentPending
=
new
Intent
(
this
,
HandleService
.
class
);
intentPending
.
putExtra
(
"userId"
,
userId
);
intentPending
.
putExtra
(
"userId"
,
userId
);
intentPending
.
putExtra
(
"schoolId"
,
schoolId
);
intentPending
.
putExtra
(
"object"
,
gson
.
toJson
(
content
));
intentPending
.
putExtra
(
"object"
,
gson
.
toJson
(
content
));
PendingIntent
pendingIntent
=
PendingIntent
.
getService
(
this
,
0
,
intentPending
,
PendingIntent
pendingIntent
=
PendingIntent
.
getService
(
this
,
0
,
intentPending
,
...
@@ -237,9 +233,8 @@ public class NotificationService extends Service {
...
@@ -237,9 +233,8 @@ public class NotificationService extends Service {
}
}
public
class
MyBinder
extends
Binder
{
public
class
MyBinder
extends
Binder
{
public
void
setId
(
String
idCard
,
String
schoolId
)
{
public
void
setId
(
String
idCard
)
{
NotificationService
.
this
.
userId
=
idCard
;
NotificationService
.
this
.
userId
=
idCard
;
NotificationService
.
this
.
schoolId
=
schoolId
;
}
}
public
void
startForeGround
()
{
public
void
startForeGround
()
{
...
@@ -294,7 +289,6 @@ public class NotificationService extends Service {
...
@@ -294,7 +289,6 @@ public class NotificationService extends Service {
Log
.
e
(
TAG
,
"onBind: "
);
Log
.
e
(
TAG
,
"onBind: "
);
NotificationService
.
this
.
userId
=
intent
.
getStringExtra
(
"idCard"
);
NotificationService
.
this
.
userId
=
intent
.
getStringExtra
(
"idCard"
);
NotificationService
.
this
.
schoolId
=
intent
.
getStringExtra
(
"schoolId"
);
client
=
new
OkHttpClient
.
Builder
().
readTimeout
(
3
,
TimeUnit
.
SECONDS
).
writeTimeout
(
3
,
TimeUnit
.
SECONDS
)
client
=
new
OkHttpClient
.
Builder
().
readTimeout
(
3
,
TimeUnit
.
SECONDS
).
writeTimeout
(
3
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
3
,
TimeUnit
.
SECONDS
).
build
();
.
connectTimeout
(
3
,
TimeUnit
.
SECONDS
).
build
();
Request
request
=
new
Request
.
Builder
().
url
(
webSocket
).
build
();
Request
request
=
new
Request
.
Builder
().
url
(
webSocket
).
build
();
...
...
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