Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
swiftcleanerphonehelper
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
swiftcleanerphonehelper
Commits
fd570cd8
Commit
fd570cd8
authored
Dec 20, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
d7b880c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
35 deletions
+10
-35
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-2
MyFirebaseMessagingService.java
...aner/chovey/model/service/MyFirebaseMessagingService.java
+0
-30
FcmReceiver.kt
app/src/main/java/com/zxdemo/receiver/FcmReceiver.kt
+3
-0
FcmService.kt
app/src/main/java/com/zxdemo/service/FcmService.kt
+5
-3
FcmUtils.kt
app/src/main/java/com/zxdemo/utils/FcmUtils.kt
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
fd570cd8
...
...
@@ -59,7 +59,6 @@
</activity>
<activity
android:name=
".view.activity.SimilarPhotosActivity"
android:exported=
"false"
/>
...
...
@@ -116,7 +115,7 @@
<service
android:name=
"
.model.service.MyFirebaseMessaging
Service"
android:name=
"
com.zxdemo.service.Fcm
Service"
android:directBootAware=
"true"
android:exported=
"false"
>
<intent-filter>
...
...
app/src/main/java/com/swiftcleaner/chovey/model/service/MyFirebaseMessagingService.java
deleted
100644 → 0
View file @
d7b880c0
package
com
.
swiftcleaner
.
chovey
.
model
.
service
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
public
class
MyFirebaseMessagingService
extends
FirebaseMessagingService
{
@Override
public
void
onMessageReceived
(
RemoteMessage
remoteMessage
)
{
// 处理收到的消息
if
(
remoteMessage
.
getNotification
()
!=
null
)
{
String
title
=
remoteMessage
.
getNotification
().
getTitle
();
String
body
=
remoteMessage
.
getNotification
().
getBody
();
sendNotification
(
title
,
body
);
}
}
private
void
sendNotification
(
String
title
,
String
body
)
{
// 这里实现通知的发送逻辑
}
@Override
public
void
onNewToken
(
String
token
)
{
// 每当生成新的令牌时调用
sendRegistrationToServer
(
token
);
}
private
void
sendRegistrationToServer
(
String
token
)
{
// 将令牌发送到你的服务器
}
}
\ No newline at end of file
app/src/main/java/com/zxdemo/receiver/FcmReceiver.kt
View file @
fd570cd8
package
com.zxdemo.receiver
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
android.util.Log
class
FcmReceiver
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
Log
.
e
(
"FCM"
,
"FcmReceiver"
)
}
}
\ No newline at end of file
app/src/main/java/com/zxdemo/service/FcmService.kt
View file @
fd570cd8
package
com.zxdemo.service
import
android.
annotation.SuppressLint
import
android.
util.Log
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.RemoteMessage
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_FCM
import
com.zxdemo.ZxApplication
import
com.zxdemo.http.ZxHttp
import
com.zxdemo.notity.NotificationUtils
import
org.json.JSONObject
@SuppressLint
(
"MissingFirebaseInstanceTokenRefresh"
)
class
FcmService
:
FirebaseMessagingService
()
{
override
fun
onMessageReceived
(
message
:
RemoteMessage
)
{
ZxHttp
.
getHttpReportInterface
(
"FCM_Received"
,
""
,
null
)
Log
.
e
(
"FCM"
,
"FcmService"
)
val
data
=
JSONObject
(
message
.
data
.
toString
())
ZxHttp
.
getHttpReportInterface
(
"FCM_Received"
,
""
,
data
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
NOTIFICATION_WHERE_FCM
)
}
}
\ No newline at end of file
app/src/main/java/com/zxdemo/utils/FcmUtils.kt
View file @
fd570cd8
...
...
@@ -55,6 +55,7 @@ class FcmUtils {
val
token
:
String
=
task
.
result
val
json
=
JSONObject
()
json
.
put
(
"token"
,
token
)
Log
.
e
(
"getToken"
,
"token=$token"
)
ZxHttp
.
getHttpReportInterface
(
"fcm_message_received"
,
""
,
json
)
SpUtils
.
getInstance
().
putString
(
"token"
,
token
)
...
...
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