Android GCM推送通知有时无法发送

时间:2016-07-21 07:30:45

标签: android push-notification google-cloud-messaging

我在Android应用中实现了GCM。我无法理解为什么有时会收到推送通知,有时我也不会得到。

GcmBroadcastReceiver

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        ComponentName comp = new ComponentName(context.getPackageName(),
                GCMNotificationIntentService.class.getName());
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}

GCMNotificationIntentService

public class GCMNotificationIntentService extends IntentService {

    public GCMNotificationIntentService() {
        super("GCMNotificationIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Bundle extras = intent.getExtras();

        String Request_Type,Msg="",Time="",Date="",Firmid = "";

        String message = intent.getExtras().getString("price");
    }
}

我还能做些什么来确保每次都提供推送通知吗?

0 个答案:

没有答案