2015-12-10 28 views
1

我嘗試使用下面的代碼來獲得installation idobject id從解析:對象ID和安裝ID給空值

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

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

我在應用程序類機器人的使用上面的代碼。都給我空。有時他們會給我價值,但不會在解析控制檯中顯示它的條目。任何人都可以幫助我這個,我在做什麼錯誤。提前致謝。

回答

1

首先您訂閱解析推送,然後更新安裝表中的記錄。

ParsePush.subscribeInBackground(「APP_NAME」);

在訂閱安裝調用後獲取objectId和installationId。

你這樣的代碼:

在你的應用類

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

在你的活動要得到這個ID的: ParseInstallation.getCurrentInstallation().getObjectId() and ParseInstallation.getCurrentInstallation().getInstallationId()