這很簡單,當您在移動設備上首次使用解析時,它就像魅力一樣。 當您重新安裝應用程序時,它會擰緊所有內容。「至少要在此操作中指定一個ID字段(installationId,deviceToken)」解析
正如Eran上stackoverflow說:
「PushService.subscribe似乎緩存認購本地存儲,以避免重新訂閱當你多次啓動應用程序 這是第一個參數。該方法用於: 背景 - 這是用來訪問本地存儲緩存認購,所以當前必須是一個可行的情況下 (引自here)
然而,當y。如果您卸載該應用程序,該應用程序的本地存儲將從您的設備中刪除,因此新安裝將導致PushService.subscribe重新註冊到Google Cloud Messaging。如果新註冊返回一個新的註冊ID,則Parse將有兩個註冊ID,可用於將推送通知發送到您的應用程序,並且它們都將鏈接到您提供用於訂閱的相同userName。因此,向該用戶名發送通知會將其發送到兩個註冊ID,導致它到達兩次。
當解析發送給你的通知,他們應該從谷歌獲得與canonical_registration_id的響應,這將讓他們知道你的應用程序在設備上相關聯的註冊ID之一是老了,不應該再使用。因此(假設解析有一個體面的實施GCM)的下一次發送通知到您的設備的時候,你應該得到它只有一次「
下面是安裝我的源代碼。
String androidId = Secure.getString(getApplicationContext().getContentResolver(),Secure.ANDROID_ID);
Parse.initialize(this, "KEY1", "KEY2");
PushService.setDefaultPushCallback(this, ParseActivity.class);
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("UniqueId",androidId);
installation.setObjectId(null);
installation.saveInBackground();
我的堆棧跟蹤(如每個人):
05-20 19:47:35.630: E/ParseCommandCache(6497): com.parse.ParseException: at least one ID field (installationId,deviceToken) must be specified in this operation
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.ParseCommand.onPostExecute(ParseCommand.java:334)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.ParseRequest$5.then(ParseRequest.java:321)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.ParseRequest$5.then(ParseRequest.java:318)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11.run(Task.java:481)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeAfterTask(Task.java:477)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWithTask(Task.java:353)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWithTask(Task.java:364)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$9.then(Task.java:410)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$9.then(Task.java:402)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11.run(Task.java:481)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeAfterTask(Task.java:477)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$400(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$7.then(Task.java:346)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$7.then(Task.java:343)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.runContinuations(Task.java:510)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$800(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:493)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$10.run(Task.java:448)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeImmediately(Task.java:444)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$300(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$6.then(Task.java:311)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$6.then(Task.java:308)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.runContinuations(Task.java:510)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$800(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:493)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$10.run(Task.java:448)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeImmediately(Task.java:444)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$300(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$6.then(Task.java:311)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$6.then(Task.java:308)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.runContinuations(Task.java:510)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$800(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:493)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$10.run(Task.java:448)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeImmediately(Task.java:444)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWith(Task.java:318)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWith(Task.java:329)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11.run(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeAfterTask(Task.java:477)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$400(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$7.then(Task.java:346)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$7.then(Task.java:343)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.runContinuations(Task.java:510)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.access$800(Task.java:22)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:493)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11$1.then(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$10.run(Task.java:448)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.completeImmediately(Task.java:444)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWith(Task.java:318)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task.continueWith(Task.java:329)
05-20 19:47:35.630: E/ParseCommandCache(6497): at com.parse.Task$11.run(Task.java:485)
05-20 19:47:35.630: E/ParseCommandCache(6497): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
05-20 19:47:35.630: E/ParseCommandCache(6497): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
05-20 19:47:35.630: E/ParseCommandCache(6497): at java.lang.Thread.run(Thread.java:841)
05-20 19:48:32.615: D/Request(6497): Warning: Sessionless Request needs token but missing either application ID or client token.
因爲我還沒有發現任何真正的解決辦法,我問這裏
謝謝
您是否找到解決方案? –
@Binghammer你有同樣的問題嗎?我仍然沒有解決方案...已經在'Parse'論壇上提出問題,並在Facebook Developers中放置了一個新Bug。 –
是的,我有同樣的問題。檢查我的問題,也許它可以幫助你? http://stackoverflow.com/questions/23860586/facebook-parse-login-behaving-strange –