Search in sources :

Example 6 with GoogleCloudMessaging

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);
    }
}
Also used : GoogleCloudMessaging(com.google.android.gms.gcm.GoogleCloudMessaging)

Aggregations

GoogleCloudMessaging (com.google.android.gms.gcm.GoogleCloudMessaging)6 Bundle (android.os.Bundle)3 IOException (java.io.IOException)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 OSUtils.getResourceString (com.onesignal.OSUtils.getResourceString)1 JSONObject (org.json.JSONObject)1