Les Notifications Push lorsque l'application est fermée

Savez-vous si il est possible de recevoir des notifications de google cloud message lorsque l'application est entièrement fermé?

Je sais que si elle est ouverte ou dans le fond oui, mais peut-il être programmé de toute façon, afin de les recevoir?

EDIT:

Je continue sans de recevoir des notifications lorsque l'application est fermée.

J'ai collé le code dans le cas où j'ai une erreur et je ne suis pas le regarder.

MANIFESTE

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.frab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.frab.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission
android:name="com.frab.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.frab.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".GGMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.something" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>

RÉCEPTEUR DE RADIODIFFUSION

package com.something;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.activities.SignIn;
import com.google.android.gcm.GCMBaseIntentService;
import com.objects.Globals;
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GGM <-----> FRAB";
private Bundle extras;
public GCMIntentService() {
super(Globals.SENDER_ID);
}
@Override
public void onDestroy() {
Log.d(TAG, "terminando servicio");
}
@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "onRegistered: registrationId=" + registrationId);
}
@Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "onUnregistered: registrationId = " + registrationId);
}
@Override
protected void onMessage(Context context, Intent data) {
extras = data.getExtras();
String message = extras.getString("msg");
Log.d("******", message);
sendNotification(message);
}
@Override
protected void onError(Context arg0, String errorId) {
Log.e(TAG, "onError: errorId = " + errorId);
}    
}
package com.something;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
public class GGMBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
//Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}

Lorsque l'application est ouverte : OK

Lorsque l'application est en arrière-plan : Ok

Lorsque l'application est fermée avec force par l'utilisateur : notifications n'arrivent pas

Quel est le problème?

Merci beaucoup.

  • user3757628 : Comment avez-vous résolu le problème?
InformationsquelleAutor user3757628 | 2014-06-19