Fixes for push notifications

This commit is contained in:
Sylvain Berfini 2016-05-04 15:21:05 +02:00
parent 76ae466b08
commit 1b3339928b
2 changed files with 2 additions and 3 deletions

View file

@ -988,6 +988,7 @@ public class LinphonePreferences {
public void setPushNotificationRegistrationID(String regId) {
getConfig().setString("app", "push_notification_regid", regId);
setPushNotificationEnabled(isPushNotificationEnabled());
}
public String getPushNotificationRegistrationID() {

View file

@ -46,11 +46,9 @@ public class ApiEightPlus {
final String regId = (String)GCMRegistrar.getMethod("getRegistrationId", Context.class).invoke(null, context);
String newPushSenderID = context.getString(R.string.push_sender_id);
String currentPushSenderID = LinphonePreferences.instance().getPushNotificationRegistrationID();
if (regId.equals("") || currentPushSenderID == null || !currentPushSenderID.equals(newPushSenderID)) {
if (regId.equals("") || currentPushSenderID == null) {
GCMRegistrar.getMethod("register", Context.class, String[].class).invoke(null, context, new String[]{newPushSenderID});
Log.d("Push Notification: storing current sender id = " + newPushSenderID);
LinphonePreferences.instance().setPushNotificationRegistrationID(newPushSenderID);
} else {
Log.d("Push Notification: already registered with id = " + regId);
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);