use of com.google.android.gms.gcm.GoogleCloudMessaging in project Signal-Android by WhisperSystems.
the class GcmBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Log.w(TAG, "GCM message...");
if (!TextSecurePreferences.isPushRegistered(context)) {
Log.w(TAG, "Not push registered!");
return;
}
String messageData = intent.getStringExtra("message");
String receiptData = intent.getStringExtra("receipt");
if (!TextUtils.isEmpty(messageData))
handleReceivedMessage(context, messageData);
else if (!TextUtils.isEmpty(receiptData))
handleReceivedMessage(context, receiptData);
else if (intent.hasExtra("notification"))
handleReceivedNotification(context);
}
}
Aggregations