allow fcm for all flavours

This commit is contained in:
B. Petersen 2024-05-02 15:29:07 +02:00 committed by bjoern
parent 256c010b61
commit 3cafdaf57e
3 changed files with 69 additions and 9 deletions

View file

@ -1,6 +1,6 @@
plugins {
id 'com.android.application' version '8.1.4'
id 'com.google.gms.google-services' version '4.4.1' apply false // TODO: apply below as needed using "apply plugin" or so
id 'com.google.gms.google-services' version '4.4.1'
}
repositories {

View file

@ -23,6 +23,63 @@
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:922391085500:android:6f54e2c4e49405673e2bb9",
"android_client_info": {
"package_name": "chat.delta.beta"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBYH8Iznh8btYX7g_udv_bu68VH30zzxho"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:922391085500:android:92b4cf12669cc2083e2bb9",
"android_client_info": {
"package_name": "com.b44t.messenger"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBYH8Iznh8btYX7g_udv_bu68VH30zzxho"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:922391085500:android:228a205b8aa2bacc3e2bb9",
"android_client_info": {
"package_name": "com.b44t.messenger.beta"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBYH8Iznh8btYX7g_udv_bu68VH30zzxho"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"

View file

@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.util.Util;
public class FcmReceiveService extends FirebaseMessagingService {
private static final String TAG = FcmReceiveService.class.getSimpleName();
private static final String TOKEN_PREFIX = "fcm:";
private static String prefixedToken;
public static void register(Context context) {
@ -41,19 +40,23 @@ public class FcmReceiveService extends FirebaseMessagingService {
return;
}
String prefixedToken = TOKEN_PREFIX + rawToken;
synchronized (FcmReceiveService.TOKEN_PREFIX) {
String prefixedToken = addPrefix(rawToken);
synchronized (FcmReceiveService.TAG) {
FcmReceiveService.prefixedToken = prefixedToken;
}
Log.w(TAG, "FCM token for " + BuildConfig.APPLICATION_ID + ": " + prefixedToken);
Log.w(TAG, "FCM token: " + prefixedToken);
ApplicationContext.dcAccounts.setPushDeviceToken(prefixedToken);
});
}
private static String addPrefix(String rawToken) {
return "fcm-" + BuildConfig.APPLICATION_ID + ":" + rawToken;
}
@Nullable
public static String getToken() {
synchronized (FcmReceiveService.TOKEN_PREFIX) {
synchronized (FcmReceiveService.TAG) {
return FcmReceiveService.prefixedToken;
}
}
@ -65,12 +68,12 @@ public class FcmReceiveService extends FirebaseMessagingService {
@Override
public void onNewToken(@NonNull String rawToken) {
String prefixedToken = TOKEN_PREFIX + rawToken;
synchronized (FcmReceiveService.TOKEN_PREFIX) {
String prefixedToken = addPrefix(rawToken) ;
synchronized (FcmReceiveService.TAG) {
FcmReceiveService.prefixedToken = prefixedToken;
}
Log.i(TAG, "new FCM token for" + BuildConfig.APPLICATION_ID + ": " + prefixedToken);
Log.i(TAG, "new FCM token: " + prefixedToken);
ApplicationContext.dcAccounts.setPushDeviceToken(prefixedToken);
}
}