Commit 512d392a authored by wanglei's avatar wanglei

...fcm

parent df6e2756
......@@ -13,7 +13,7 @@ android {
compileSdk = 34
defaultConfig {
applicationId = "com.base.locationsharewhite"
applicationId = "com.tool.advanced.cleaner"
minSdk = 24
targetSdk = 34
versionCode = 1
......
{
"project_info": {
"project_number": "953792647345",
"project_id": "pdf-test-d0ae7",
"storage_bucket": "pdf-test-d0ae7.appspot.com"
"project_number": "755421476297",
"project_id": "comtooladvancedcleaner",
"storage_bucket": "comtooladvancedcleaner.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:953792647345:android:c5234e8bfc859f8b20d290",
"mobilesdk_app_id": "1:755421476297:android:c66d8129d83b17e8af6418",
"android_client_info": {
"package_name": "com.base.locationsharewhite"
"package_name": "com.tool.advanced.cleaner"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBT6B1oPmkojGX0TgBOI9bDkx5pdEFXWoo"
"current_key": "AIzaSyAhCB4trMZPymkWCNl_m-bFGPpASG6bsQI"
}
],
"services": {
......
......@@ -131,7 +131,7 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="confine.scream" />
<category android:name="com.tool.advanced.cleaner" />
</intent-filter>
</receiver>
<receiver
......
package com.base.locationsharewhite.fcm
import android.content.Context
import android.util.Log
import com.base.locationsharewhite.helper.EventUtils
......@@ -11,6 +13,7 @@ import com.google.firebase.messaging.FirebaseMessaging
import org.json.JSONObject
object FCMManager {
fun initFirebase(context: Context?) {
FirebaseApp.initializeApp(context!!)
LogEx.logDebug("initFirebase", "initFirebase")
......@@ -40,6 +43,9 @@ object FCMManager {
}
}
/**
* 有vpn有google商店才能获取
*/
private fun getToken() {
FirebaseMessaging.getInstance().token
.addOnCompleteListener(object : OnCompleteListener<String> {
......@@ -59,7 +65,7 @@ object FCMManager {
AppPreferences.getInstance().put("token", token)
// Handle new token
Log.d("FCM", "FCM Registration Token: $token")
LogEx.logDebug("FCM", "FCM Registration Token: $token")
}
})
}
......
package com.base.locationsharewhite.fcm;
package com.base.locationsharewhite.fcm
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.applovin.sdk.AppLovinSdkUtils.runOnUiThread
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import com.base.locationsharewhite.helper.EventUtils.event
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.LogEx.logDebug
import com.base.locationsharewhite.utils.ToastUtils.toast
import com.base.locationsharewhite.helper.EventUtils;
import com.base.locationsharewhite.utils.LogEx;
class FcmReceiver : BroadcastReceiver() {
private val TAG = "FcmReceiver"
override fun onReceive(context: Context, intent: Intent) {
LogEx.logDebug("FCM", "FcmReceiver")
event("FCM_Received", null, null, false)
public class FcmReceiver extends BroadcastReceiver {
private String TAG = "FcmReceiver";
sendNotificationIfCan(context, PopupConstObject.POPUP_WHERE_FCM, null)
@Override
public void onReceive(Context context, Intent intent) {
LogEx.INSTANCE.logDebug(TAG, "onReceive", false);
EventUtils.INSTANCE.event("FCM_Received", null, null, false);
NotificationUiUtil.INSTANCE.sendNotificationIfCan(context, PopupConstObject.POPUP_WHERE_FCM, null);
if (BuildConfig.DEBUG) {
runOnUiThread {
runCatching {
MyApplication.appContext.toast("FcmReceiver fcm")
}
}
}
}
}
package com.base.locationsharewhite.fcm;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.base.locationsharewhite.helper.EventUtils;
import com.base.locationsharewhite.utils.LogEx;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
package com.base.locationsharewhite.fcm
import android.annotation.SuppressLint
import com.applovin.sdk.AppLovinSdkUtils.runOnUiThread
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import com.base.locationsharewhite.helper.EventUtils.event
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.ToastUtils.toast
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import org.json.JSONException
import org.json.JSONObject
@SuppressLint("MissingFirebaseInstanceTokenRefresh")
public class MessagingService extends FirebaseMessagingService {
private static final String TAG = "MessagingService";
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
LogEx.INSTANCE.logDebug(TAG, "onMessageReceived", false);
EventUtils.INSTANCE.event("FCM_Received", null, null, false);
NotificationUiUtil.INSTANCE.sendNotificationIfCan(this, PopupConstObject.POPUP_WHERE_FCM, null);
class MessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
val id = remoteMessage.messageId
val ext = JSONObject()
try {
ext.put("getMessageType", remoteMessage.messageType)
ext.put("getData", remoteMessage.data)
ext.put("getCollapseKey", remoteMessage.collapseKey)
ext.put("getFrom", remoteMessage.from)
ext.put("getPriority", remoteMessage.priority)
ext.put("getSenderId", remoteMessage.senderId)
ext.put("getSentTime", remoteMessage.sentTime)
} catch (e: JSONException) {
event("FCM_Received_Error", id, ext, false)
throw RuntimeException(e)
} finally {
}
event("FCM_Received", id, ext, false)
LogEx.logDebug("FCM", "MessagingService")
sendNotificationIfCan(this, PopupConstObject.POPUP_WHERE_FCM, null)
if (BuildConfig.DEBUG) {
runOnUiThread {
runCatching {
MyApplication.appContext.toast("MessagingService fcm")
}
}
}
}
companion object {
private const val TAG = "MessagingService"
}
}
\ No newline at end of file
package com.base.locationsharewhite.helper
import FCMManager
import com.base.locationsharewhite.fcm.FCMManager
import android.app.Activity
import android.app.Application
import android.content.Context
......@@ -21,6 +21,7 @@ import com.base.locationsharewhite.service.StayJobService.Companion.startJob
import com.base.locationsharewhite.ui.splash.SplashActivity
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx
import com.facebook.FacebookSdk
import com.hjq.language.MultiLanguages
import com.hjq.language.OnLanguageListener
import java.util.Locale
......@@ -81,9 +82,10 @@ class MyApplication : Application() {
}
private fun initApp() {
// FacebookSdk.sdkInitialize(applicationContext)
FacebookSdk.sdkInitialize(applicationContext)
val token = AppPreferences.getInstance().getString("token", "")
val topic = AppConfig.packageName + "_push"
LogEx.logDebug(TAG, "topic=${topic}")
LogEx.logDebug(TAG, "topic=${topic} token=$token")
FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(topic)
InstallHelps.init()
......
......@@ -94,7 +94,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mainPresenter.startLocationJob(lifecycleScope)
showAllowAllTimeDialog()
changeLanguage(this)
// changeLanguage(this)
}
private fun showNotificationDialog() {
......
......@@ -61,7 +61,7 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
override fun onResumeOneShoot() {
super.onResumeOneShoot()
changeLanguage(this)
// changeLanguage(this)
}
override fun onResume() {
......
......@@ -99,7 +99,8 @@
android:layout_marginTop="18dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">
android:focusable="true"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
......
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