The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Google::C2DM - Google C2DM Client

SYNOPSIS

  use WWW::Google::C2DM;
  use WWW::Google::ClientLogin;

  my $auth_token = WWW::Google::ClientLogin->new(...)->authentication->auth_token;
  my $c2dm = WWW::Google::C2DM->new(auth_token => $auth_token);
  my $res  = $c2dm->send(
      registration_id => $registration_id,
      collapse_key    => $collapse_key,
      'data.message'  => $message,
  );
  die $res->error_code if $res->is_error;
  my $id = $res->id;

DESCRIPTION

WWW::Google::C2DM is HTTP Client for Google C2DM service.

SEE ALSO http://code.google.com/intl/us/android/c2dm/

METHODS

new(%args)

Create a WWW::Google::C2DM instance.

  my $c2dm = WWW::Google::C2DM->new(auth_token => $auth_token);

Supported parameters are:

auth_token : Str

Required. authorization token from Google ClientLogin. SEE ALSO WWW::Google::ClientLogin.

ua : LWP::UserAgent

Optional.

send(%args)

Send to C2DM. Returned values is WWW::Google::C2DM::Response object.

  my $res = $c2dm->send(
      registration_id  => $registration_id,
      collapse_key     => $collapse_key,
      'data.message'   => $message,
      delay_while_idle => $bool,
  );

  say $res->error_code if $res->is_error;

Supported parameters are:

registration_id : Str

Required. The registration ID retrieved from the Android application on the phone.

  registration_id => $registration_id,
collapse_key : Str

Required. An arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client.

  collapse_key => $collapse_key,
delay_while_idle : Bool

Optional. If included, indicates that the message should not be sent immediately if the device is idle.

  delay_while_idle => 1,
data.<key> : Str || data : HASHREF

Optional. Payload data, expressed as key-value pairs.

  my $res = $c2dm->send(
      ....
      'data.message' => $message,
      'data.name'    => $name,
  );

Or you can specify data. Value is must be HASHREF.

  data => {
      message => $message,
      name    => $name,
  },
  # Equals:
  # 'data.message' => $message,
  # 'data.name'    => $name,

Or you can specify both option.

SEE ALSO http://code.google.com/intl/us/android/c2dm/#push

AUTHOR

xaicron <xaicron@cpan.org>

COPYRIGHT

Copyright 2011 - xaicron

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO