Read firebase push sender if from google-services.json instead of non_localizable_custom

This commit is contained in:
Sylvain Berfini 2019-02-19 10:49:25 +01:00
parent 85fa30623d
commit 86ca3ac16b
3 changed files with 16 additions and 7 deletions

View file

@ -99,6 +99,10 @@ android {
resValue "string", "sync_account_type", getPackageName() + ".sync"
resValue "string", "file_provider", getPackageName() + ".provider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
if (!firebaseEnabled()) {
resValue "string", "gcm_defaultSenderId", "none"
}
}
debug {
applicationIdSuffix ".debug"
@ -109,6 +113,10 @@ android {
resValue "string", "sync_account_type", getPackageName() + ".sync"
resValue "string", "file_provider", getPackageName() + ".provider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
if (!firebaseEnabled()) {
resValue "string", "gcm_defaultSenderId", "none"
}
}
}

View file

@ -754,6 +754,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private void initPushNotificationsService() {
if (getString(R.string.push_type).equals("firebase")) {
Log.i(
"[Push Notification] firebase push sender id "
+ getString(R.string.gcm_defaultSenderId));
try {
FirebaseInstanceId.getInstance()
.getInstanceId()
@ -762,21 +765,19 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w(
Log.e(
"[Push Notification] firebase getInstanceId failed: "
+ task.getException());
return;
}
String token = task.getResult().getToken();
Log.i(
"[Push Notification] init push notif service token is: "
+ token);
Log.i("[Push Notification] firebase token is: " + token);
LinphonePreferences.instance()
.setPushNotificationRegistrationID(token);
}
});
} catch (Exception e) {
Log.i("[Push Notification] firebase not available.");
Log.e("[Push Notification] firebase not available.");
}
}
}

View file

@ -950,7 +950,7 @@ public class LinphonePreferences {
if (enable) {
// Add push infos to exisiting proxy configs
String regId = getPushNotificationRegistrationID();
String appId = getString(R.string.push_sender_id);
String appId = getString(R.string.gcm_defaultSenderId);
if (regId != null && lc.getProxyConfigList().length > 0) {
for (ProxyConfig lpc : lc.getProxyConfigList()) {
if (lpc == null) continue;
@ -1558,7 +1558,7 @@ public class LinphonePreferences {
prxCfg.setQualityReportingInterval(tempQualityReportingInterval);
String regId = LinphonePreferences.instance().getPushNotificationRegistrationID();
String appId = LinphonePreferences.instance().getString(R.string.push_sender_id);
String appId = LinphonePreferences.instance().getString(R.string.gcm_defaultSenderId);
if (regId != null && LinphonePreferences.instance().isPushNotificationEnabled()) {
String contactInfos =
"app-id="