Google Cloud Messaging推送通知仅适用一次(PHP,Android)

I am having trouble getting Google Cloud Messaging for Android working.

I have had it working before but it decides to stop working after the first couple of times.

In order to get it working again I have to delete my API key and recreate it.

I am using PHP with a SERVER API key with a IP whitelist of ::/0 (All IPv6 apparently)

Note: My android app requests a device message key each time the app is opened (Usually returns the same message key)

The Error I get is: Unauthorized Error 401

When I got to the following url to check my app message id i get 'invalid token'.

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=APA91bHuQEWGsvlRUhlSztNpqLVOZQGZPiGFHjQw2plcF-z8t29zvNNgNoDiRe-CbY9Fb-XcPQAFqJvy4HBfWTrTPPpzcY3pd5vX38WGalOsZ5iDiJeglpafLTC7eFkN4UA9JPKWZ4lqNiGLoH3w8W_GpFAFW5F-kLLzcbrPxwSFqyfUpmM8-14

The PHP code I am using is:

$data = array( 'message' => 'Hello World!222!' );

$ids = array('APA91bHuQEWGsvlRUhlSztNpqLVOZQGZPiGFHjQw2plcF-z8t29zvNNgNoDiRe-CbY9Fb-XcPQAFqJvy4HBfWTrTPPpzcY3pd5vX38WGalOsZ5iDiJeglpafLTC7eFkN4UA9JPKWZ4lqNiGLoH3w8W_GpFAFW5F-kLLzcbrPxwSFqyfUpmM8-14');

$apiKey = 'AIzaSyATkp_UTZh....'; //obviously the complete key is used...

$url = 'https://android.googleapis.com/gcm/send';

$post = array('registration_ids'  => $ids, 'data' => $data);

$headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json');

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $url );

curl_setopt( $ch, CURLOPT_POST, true );

curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );

$result = curl_exec( $ch );

if ( curl_errno( $ch ) )
{
    echo 'GCM error: ' . curl_error( $ch );
}

curl_close( $ch );

echo $result;

Thanks for any help given.

EDIT: It seems to work since I unregistered my device and reregistered it with GCM. I am not sure if this is a permanent fix but it works for now.