When receiving a push, do work on main thread

This commit is contained in:
Sylvain Berfini 2016-09-08 11:35:07 +02:00
parent 7b8029c35f
commit 5378f46b56

View file

@ -77,20 +77,29 @@ public class GCMService extends GCMBaseIntentService {
}
@Override
protected void onRegistered(Context context, String regId) {
protected void onRegistered(Context context, final String regId) {
initLogger(context);
Log.d("[Push Notification] Registered: " + regId);
UIThreadDispatcher.dispatch(new Runnable(){
@Override
public void run() {
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
}
});
}
@Override
protected void onUnregistered(Context context, String regId) {
initLogger(context);
Log.w("[Push Notification] Unregistered: " + regId);
UIThreadDispatcher.dispatch(new Runnable(){
@Override
public void run() {
LinphonePreferences.instance().setPushNotificationRegistrationID(null);
}
});
}
protected String[] getSenderIds(Context context) {
return new String[] { context.getString(R.string.push_sender_id) };