Cloud 无法使用Google云消息/GCM从服务器向客户端发布消息

Cloud 无法使用Google云消息/GCM从服务器向客户端发布消息,cloud,messaging,google-cloud-messaging,Cloud,Messaging,Google Cloud Messaging,我能够使用该代码在我的客户端应用程序上获得注册密钥 GCMRegistar.registerthis,805421596082 我收到了注册号 我正在使用以下JAVA代码发布消息 import java.util.ArrayList; import com.google.android.gcm.server.Message; import com.google.android.gcm.server.MulticastResult; import com.google.android.gc

我能够使用该代码在我的客户端应用程序上获得注册密钥

GCMRegistar.registerthis,805421596082

我收到了注册号

我正在使用以下JAVA代码发布消息

import java.util.ArrayList; 

import com.google.android.gcm.server.Message; 
import com.google.android.gcm.server.MulticastResult; 
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender; 

public class Notify { 

    public static void main(String args[]) { 

        try { 

            Sender sender = new Sender("AIzaSyAj0cooI3YxBzbug-6CcmJQdRXxGKphRbU"); // This is the server api key 

            Message message = new Message.Builder() 
            .collapseKey("1") 
            .timeToLive(3) 
            .delayWhileIdle(true) 
            .addData("message", 
            "this text will be seen in notification bar!!") 
            .build(); 

            Result result = sender 
            .send(message, 
            "APA91bEMi5lmYKxaJX4-80eUp1JsW50_jSbZoqUs16xswI9EuXK_Km3qyuGxvoqKBvg9_5009naFrF7VKBknOKEo946SWtH57cd_m5BbTxpgaaT_Iy-m9McyV6aqy6BjxAy0d57arqp2yq6mHZrgw7qx-o4ntv7T2Q",  // This is the registration id
            1); 


        } catch (Exception e) { 
            e.printStackTrace(); 
        } 

    } 
}
当我记录结果值时,我得到[errorCode=MismatchSenderId]


我不能再继续下去了。如果有人能为我推荐一个解决方案,那将非常有帮助。

API密钥和senderID应该属于同一个帐户。您还应该使用使用给定senderID生成的注册ID。检查你的钥匙

下文对此进行了解释:

注册ID绑定到某一组发件人。当 应用程序注册GCM使用,它必须指定要使用的发件人 允许发送消息。确保您在使用时使用了其中一个 正在尝试向设备发送消息。如果你换一个不同的 发件人,现有注册ID将不起作用。发生错误时发生 代码不匹配


API密钥和senderID应属于同一帐户。您还应该使用使用给定senderID生成的注册ID。检查你的钥匙

下文对此进行了解释:

注册ID绑定到某一组发件人。当 应用程序注册GCM使用,它必须指定要使用的发件人 允许发送消息。确保您在使用时使用了其中一个 正在尝试向设备发送消息。如果你换一个不同的 发件人,现有注册ID将不起作用。发生错误时发生 代码不匹配