Android如何使用drupal服务器接收推送通知

Android如何使用drupal服务器接收推送通知,android,drupal,drupal-7,notifications,Android,Drupal,Drupal 7,Notifications,我按照教程中的所有步骤进行操作。 我的设备已使用GCM Id在drupal服务器上成功注册 我的问题是,从服务器发送推送通知时,它会显示“成功发送通知”,但此通知不会在手机上接收 有谁能告诉我该怎么做……最后我发现了我的错误 我试图在广播接收器中获取通知消息,但在这个服务onMessage(上下文,意图数据)中获取消息是错误的 }使用drupal签出node.js以获取推送通知。@Sandroid第一个链接不起作用。我还想在Drupal7站点中创建一个免费推送通知。你能和我分享一些有用的文件

我按照教程中的所有步骤进行操作。

我的设备已使用GCM Id在drupal服务器上成功注册

我的问题是,从服务器发送推送通知时,它会显示“成功发送通知”,但此通知不会在手机上接收


有谁能告诉我该怎么做……

最后我发现了我的错误

我试图在广播接收器中获取通知消息,但在这个服务onMessage(上下文,意图数据)中获取消息是错误的


}

使用drupal签出node.js以获取推送通知。@Sandroid第一个链接不起作用。我还想在Drupal7站点中创建一个免费推送通知。你能和我分享一些有用的文件吗?这样我就不必经历所有的过程了?
public class GCMIntentService extends GCMBaseIntentService{

private static final String TAG = "GCMIntentService";

public GCMIntentService() {
    super(SENDER_ID);
}

@Override
protected void onError(Context arg0, String arg1) {
    // TODO Auto-generated method stub

}

@Override
protected void onMessage(Context context, Intent data) {

    Log.i(TAG, "new message= ");
      String message = data.getExtras().getString("message");
      /*if (message.equals("") ) {
          //message="hellow senha , this is vc circle notification. You can check how it display long or short...";
          generateNotification(context, message);   
      }else{
          generateNotification(context, message);   
      }*/
      //message="hellow senha , this is vc circle notification. You can check how it display long or short...";
      generateNotification(context, message);   
}

private void generateNotification(Context context, String message) {

    int icon = R.drawable.vc_placeholder;
      long when = System.currentTimeMillis();
      NotificationManager notificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);

      Intent notificationIntent = new Intent(context, SplashScreenActivity.class);
      notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_SINGLE_TOP);
      PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0,
        notificationIntent, 0);

      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                context);

      Notification notification = mBuilder.setSmallIcon(icon).setTicker("VCCircle").setWhen(when)
                .setContentTitle(context.getString(R.string.app_name))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                .setContentIntent(resultPendingIntent)
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.vc_placeholder))
                .setContentText(message).build();

     notification.flags |= Notification.FLAG_AUTO_CANCEL;
      notificationManager.notify(0, notification);

      {
            // Wake Android Device when notification received
            PowerManager pm = (PowerManager) context
                    .getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock mWakelock = pm.newWakeLock(
                    PowerManager.FULL_WAKE_LOCK
                            | PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH");
            mWakelock.acquire();

            // Timer before putting Android Device to sleep mode.
            Timer timer = new Timer();
            TimerTask task = new TimerTask() {
                public void run() {
                    mWakelock.release();
                }
            };
            timer.schedule(task, 5000);
        }



}

@Override
protected void onRegistered(Context context, String registrationId) {
    Log.i(TAG, "Device registered: regId = " + registrationId);
    displayMessage(context, getString(R.string.gcm_registered));
    boolean te=ServerUtilities.register(context, registrationId);
    System.out.println("Device Register : "+te);
}

@Override
protected void onUnregistered(Context arg0, String arg1) {
    // TODO Auto-generated method stub

}