GCM defaultSenderID

布兰登

有人可以帮我理解以下代码中的gcm_defaultSenderId(在RegistrationIntentService.java中的onHandleIntent中找到):

InstanceID instanceID = InstanceID.getInstance(this);
            String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                    GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
            // [END get_token]
            Log.i(TAG, "GCM Registration Token: " + token);

这是来自Google示例应用,用于在您的应用中实现GCM,甚至没有在其应用中进行编译!我确定这是每个应用程序特有的。我已经将GCM API添加到我的应用程序中,只是不知道该字符串应该是什么!谢谢!

维斯科

引用文档,您可以在其中找到有关该实现的详细信息:

String authorizedEntity = PROJECT_ID; // Project id from Google Developers Console
String scope = “GCM”; // e.g. communicating using GCM, but you can use any
                      // URL-safe characters up to a maximum of 1000, or
                      // you can also leave it blank.
String token = InstanceID.getInstance().getToken(authorizedEntity,scope);

如您所见,您应该传递给的第一个参数getToken()authorizedEntity,它应该是您来自Google Developers的项目ID :)

即使GitHub中的项目具有该字符串,也不会给您带来任何好处,因为这authorizedEntity对于每个应用程序都是唯一的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章