Commit 27912a2b authored by wanglei's avatar wanglei Committed by songjianyu

[测试]fcm测试

parent c5e9ecda
......@@ -15,7 +15,7 @@ android {
compileSdk = 35
defaultConfig {
applicationId = "com.base.appzxhy2"// "com.link.play.fit.ai.test1"
applicationId = "com.link.play.fit.ai.test1"// "com.link.play.fit.ai.test1"
minSdk = 24
targetSdk = 35
versionCode = 1
......
{
"project_info": {
"project_number": "755421476297",
"project_id": "comtooladvancedcleaner",
"storage_bucket": "comtooladvancedcleaner.firebasestorage.app"
"project_number": "291586696477",
"project_id": "test1-e1db4",
"storage_bucket": "test1-e1db4.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:755421476297:android:c66d8129d83b17e8af6418",
"mobilesdk_app_id": "1:291586696477:android:44c70b7d2517719de66df4",
"android_client_info": {
"package_name": "com.base.appzxhy2"
"package_name": "com.link.play.fit.ai.test1"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAhCB4trMZPymkWCNl_m-bFGPpASG6bsQI"
"current_key": "AIzaSyBGtHDkxHwQhn4XqmmvX-TYVi--Sruj8WI"
}
],
"services": {
......
......@@ -15,6 +15,10 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".MyApplication"
android:allowBackup="true"
......@@ -164,7 +168,9 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name=".business.push.fcm.MessagingService"
android:exported="false">
android:directBootAware="true"
android:exported="false"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
......@@ -179,7 +185,7 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.tool.advanced.cleaner" />
<category android:name="com.link.play.fit.ai.test1" />
</intent-filter>
</receiver>
......
package com.base.appzxhy.push.fcm
package com.base.appzxhy.business.push.fcm
import android.content.Context
import android.util.Log
import com.base.appzxhy.SpConstObject.fcmToken
import com.base.appzxhy.business.helper.EventUtils.event
import com.base.appzxhy.utils.AppPreferences
import com.base.appzxhy.utils.LogEx
import com.google.android.gms.tasks.OnCompleteListener
import com.google.android.gms.tasks.Task
......@@ -61,7 +61,7 @@ object FCMManager {
json.put("token", token)
event("fcm_message_received", ext = json)
AppPreferences.getInstance().put("token", token)
fcmToken = token
// Handle new token
LogEx.logDebug("FCM", "FCM Registration Token: $token")
......
......@@ -3,6 +3,7 @@ package com.base.appzxhy.business.push.fcm
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.base.appzxhy.bean.push.NotificationSendBean
import com.base.appzxhy.bean.push.NotificationSendBean.Companion.POPUP_WHERE_FCM
import com.base.appzxhy.business.helper.EventUtils.event
......@@ -13,6 +14,7 @@ class FcmReceiver : BroadcastReceiver() {
private val TAG = "FcmReceiver"
override fun onReceive(context: Context, intent: Intent) {
Log.e(TAG,"FCM_Received FcmReceiver")
event("FCM_Received", "FcmReceiver", null)
MyNotificationManager.submitSendBean(NotificationSendBean(context, POPUP_WHERE_FCM))
}
......
package com.base.appzxhy.business.push.fcm
import android.annotation.SuppressLint
import android.util.Log
import com.base.appzxhy.bean.push.NotificationSendBean
import com.base.appzxhy.bean.push.NotificationSendBean.Companion.POPUP_WHERE_FCM
import com.base.appzxhy.business.helper.EventUtils.event
......@@ -11,8 +12,11 @@ import org.json.JSONObject
@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class MessagingService : FirebaseMessagingService() {
private val TAG = "MessagingService"
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
Log.e(TAG, "FCM_Received MessagingService")
val data = JSONObject(remoteMessage.data.toString())
event("FCM_Received", "MessagingService", data)
MyNotificationManager.submitSendBean(NotificationSendBean(this, POPUP_WHERE_FCM))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment