简体   繁体   English

解析SDK中的对象ID和安装ID提供空值

[英]Object ID and Installation ID in parse SDK giving null value

I am trying to get installation id and object id from parse by using below code: 我正在尝试通过使用以下代码从解析中获取installation idobject id

Parse.initialize(this, Constants.PARSE_APPLICATION_ID, Constants.PARSE_CLIENT_KEY);

ParseInstallation.getCurrentInstallation().getObjectId() and 
ParseInstallation.getCurrentInstallation().getInstallationId().

I am using above code in application class of android. 我在android的应用程序类中使用以上代码。 both giving me null. 都给我空。 and sometimes they give values to me, but not showing its entry in parse console. 有时它们会为我提供值,但不会在解析控制台中显示其条目。 can anyone please help me this, what exactly wrong i am doing. 谁能帮我这个忙,我到底在做什么错。 Thanks in advance. 提前致谢。

First you subscribe for parse push then it update records in Installation table. 首先,您订阅解析推送,然后更新安装表中的记录。

ParsePush.subscribeInBackground("APP_NAME"); ParsePush.subscribeInBackground( “APP_NAME”);

After subscribing call on Installation to get objectId and installationId. 订阅后,请致电Installation以获取objectId和installationId。

Your Code like this : 您的代码是这样的:

In Your Application class 在您的应用程序类中

 Parse.initialize(this, Constants.PARSE_APPLICATION_ID, Constants.PARSE_CLIENT_KEY);
 ParsePush.subscribeInBackground("APP_NAME");

In your Activity where you want to get this id's : ParseInstallation.getCurrentInstallation().getObjectId() and ParseInstallation.getCurrentInstallation().getInstallationId() . 在您要获取此ID的Activity中: ParseInstallation.getCurrentInstallation().getObjectId() and ParseInstallation.getCurrentInstallation().getInstallationId()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM