Android GCM消息发送未接收

时间:2014-05-07 07:34:35

标签: java php android google-cloud-messaging

我是Android GCM服务的新手我正在用PHP发送消息 作为回应

{"multicast_id":5035179847798608085,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1399447523487490%5695579af9fd7ecd"}]}

看起来像是发送它但没有接收到我的Android应用程序

这是我的PHP代码:

     $registrationId="APA91bHx1bvBURGF4YSMDWGd5fPb33YtWfwEDspbsT-ejAYR0K_rao7NCSUtki7bP_1BvoCWn8fNpqAIPSjchvcy2JGtdJPvVC85cU9fhFoiE-Cos7PyhUhqIkpXznrD2rNhg9sVlWF2J5c9vSLLHP0LJDq5Q5M29dnUGzaROWcGBqsw3673VKM";
    // API access key from Google API's Console

    // Message to send
    $message      = "the test message";
    $tickerText   = "ticker text message";
    $contentTitle = "content title";
    $contentText  = "content body";

    //$registrationId = 'DEVICE_ID';
    $apiKey = "AIzaSyBx6hRnATNJGeYqeF4fzZLrNriuV2TRacI";

    $response = sendNotification(
        $apiKey,
        $registrationId,
        array('message' => $message, 'tickerText' => $tickerText, 'contentTitle' => $contentTitle, "contentText" => $contentText)
    );


    echo $response;




      $data = array(
            'data'=>$messageData,
            'registration_ids' => array($registrationIds)

        );


        var_dump( $headers);
        var_dump ($data);
        $ch = curl_init();
        $data= json_encode($data);

        curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
        curl_setopt( $ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send" );
        curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );

        var_dump ($data);
        $response = curl_exec($ch);
        curl_close($ch);

        return $response;
    }

需要帮助

1 个答案:

答案 0 :(得分:0)

您是否在Wifi网络上?防火墙必须允许在Gcm config 上找到5228打开 您可以使用工具来帮助检查连接GCM Server for windows