GCM como cancelar o registro de um dispositivo com o GCM e o servidor de terceiros

Eu tenho um aplicativo que usa notificações por push do GCM. Ele funciona bem e meu dispositivo registra e recebe mensagens push.

Se eu desinstalar o aplicativo do meu dispositivo, não receberei mais as mensagens como você esperaria. O TextBox no qual você envia mensagens no servidor ainda está lá depois que eu desinstalo o aplicativo, o que eu também esperava.

Eu olhei para a documentação sobre o cancelamento de registro e você pode fazê-lo manualmente ou automaticamente.

The end user uninstalls the application.
The 3rd-party server sends a message to GCM server.
The GCM server sends the message to the device.
The GCM client receives the message and queries Package Manager about whether there are broadcast receivers configured to receive it, which returns false.
The GCM client informs the GCM server that the application was uninstalled.
The GCM server marks the registration ID for deletion.
The 3rd-party server sends a message to GCM.
The GCM returns a NotRegistered error message to the 3rd-party server.
The 3rd-party deletes the registration ID.

Eu não entendo o próximo a última declaração na lista acima.

The GCM returns a NotRegistered error message to the 3rd-party server.

Como isso é alcançado?

Além disso, se o aplicativo for desinstalado do dispositivo, como ele pode fazer a instrução abaixo? Existe um método de ciclo de vida do aplicativo que é executado quando um aplicativo é removido de um dispositivo? Se houver, este é o lugar onde o código é colocado que informa o servidor GCM da desinstalação e chama um script php no servidor de terceiros que remove o regID do banco de dados?

The GCM client informs the GCM server that the application was uninstalled.

desde já, obrigado,

Matt

[edit1]

static void unregister(final Context context, final String regId) {
        Log.i(TAG, "unregistering device (regId = " + regId + ")");
        String serverUrl = SERVER_URL + "/unregister.php";
        Map<String, String> params = new HashMap<String, String>();
        params.put("regId", regId);
        try {
            post(serverUrl, params);
            GCMRegistrar.setRegisteredOnServer(context, false);
            String message = context.getString(R.string.server_unregistered);
            CommonUtilities.displayMessage(context, message);
        } catch (IOException e) {
            // At this point the device is unregistered from GCM, but still
            // registered in the server.
            // We could try to unregister again, but it is not necessary:
            // if the server tries to send a message to the device, it will get
            // a "NotRegistered" error message and should unregister the device.
            String message = context.getString(R.string.server_unregister_error,
                    e.getMessage());
            CommonUtilities.displayMessage(context, message);
        }
    }

[EDIT2] O código de cancelamento de registro abaixo é para cancelar o registro do dispositivo no servidor de terceiros após excluir o aplicativo do telefone. O código é adicionado ao tutorial abaixo.

tutorial

send_messages.php

<?php
if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    $strRegID = strval($regId);

    include_once './GCM.php';
    include_once './db_functions.php';
    $gcm = new GCM();

    $registatoin_ids = array($regId);
    $message = array("price" => $message);

    $result = $gcm->send_notification($registatoin_ids, $message);
    $db = new db_Functions();

    if (strcasecmp ( strval($result) , 'NotRegistered' )) {
    $db->deleteUser($strRegID);
    }
}
?>

db_functions.php

public function deleteUser($regid) {

    $strRegID = strval($regid);

    $serverName = "LOCALHOST\SQLEXPRESS"; 
        $uid = "gcm";     
        $pwd = "gcm";    
        $databaseName = "gcm";   

        $connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>$databaseName); 


             $db = sqlsrv_connect($serverName,$connectionInfo) or die("Unable to connect to server");

             $query = "DELETE FROM gcmUser2 WHERE gcuRegID = '$regid'";
             $result = sqlsrv_query($db, $query);


    }

questionAnswers(1)

yourAnswerToTheQuestion