I am using Google Cloud Messaging for one of my projects. I think I have configured everything correctly. I am getting the following error when I tried to send some message.

Notice: Undefined offset: 1 in gcm_action_send_message()

I can't find any information in the module documentation.

  • May you show the code you are using? – kiamlaluno Jan 17 '13 at 9:33
  • @kiamlaluno, its all set up with configuration forms i am doing nothing via code. – niksmac Jan 17 '13 at 9:42
  • 1
    this looks like something that would live better as a bug report in the issue queue than an open question here. – David Meister Jan 17 '13 at 12:31
  • @DavidMeister, This is not a bug. Lack of documentation only. See my answer. – niksmac Jan 17 '13 at 13:48
  • Not providing inline documentation for an API function is a bug in the documentation. According to drupal.org/node/1354#functions. File an issue please. – David Meister Jan 17 '13 at 14:32

I found the answer by looking the code used from the module.

function gcm_action_send_message($tokens, $keyValues, $delay_while_idle, $time_to_live, $collapse_key) {

    $gcm_message = array();
    foreach (explode(",", $keyValues) as $keyValue) {
      $temp = explode("=", $keyValue);
      $key = $temp[0];
      $value = $temp[1];
      if (isset($key) && isset($value)) {
        $gcm_message[$key] = $value;
    gcm_send_message(array_unique(explode(',', $tokens)), $gcm_message, $delay_while_idle, $time_to_live, $collapse_key);

So we need to use for key-values a value like 0=[site:name], 1=[site:mail].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.