Fix firebase (fix actually backported from dev_group_chat branch, with modifications to handle a build without the google-services jar.)
This commit is contained in:
parent
3371919087
commit
133fdb350f
2 changed files with 13 additions and 5 deletions
|
@ -803,11 +803,19 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
Log.i("[Push Notification] Assuming GCM jar is not provided.");
|
Log.i("[Push Notification] Assuming GCM jar is not provided.");
|
||||||
}
|
}
|
||||||
}else if (getString(R.string.push_type).equals("firebase")){
|
}else if (getString(R.string.push_type).equals("firebase")){
|
||||||
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
try{
|
||||||
|
Class<?> firebaseClass = Class.forName("com.google.firebase.iid.FirebaseInstanceId");
|
||||||
|
Object firebaseInstance = firebaseClass.getMethod("getInstance").invoke(null);
|
||||||
|
final String refreshedToken = (String)firebaseClass.getMethod("getToken").invoke(firebaseInstance);
|
||||||
|
|
||||||
|
//final String refreshedToken = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken();
|
||||||
if (refreshedToken != null) {
|
if (refreshedToken != null) {
|
||||||
Log.i("[Push Notification] current token is: " + refreshedToken);
|
Log.i("[Push Notification] current token is: " + refreshedToken);
|
||||||
LinphonePreferences.instance().setPushNotificationRegistrationID(refreshedToken);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(refreshedToken);
|
||||||
}
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.i("[Push Notification] firebase not available.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class FirebaseIdService extends FirebaseInstanceIdService {
|
||||||
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
||||||
android.util.Log.i("FirebaseIdService", "[Push Notification] Refreshed token: " + refreshedToken);
|
android.util.Log.i("FirebaseIdService", "[Push Notification] Refreshed token: " + refreshedToken);
|
||||||
|
|
||||||
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
UIThreadDispatcher.dispatch(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
LinphonePreferences.instance().setPushNotificationRegistrationID(refreshedToken);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(refreshedToken);
|
||||||
|
|
Loading…
Reference in a new issue