Android Parse Push notification device registration only one time on one device -
every 1 using parse service push notification in app. register time when re-install app in 1 device.then problem that,one device receive multiple notifications on each. have done code registration shown below. please me,thanks in advance.
parse.initialize(this, parse_app_id, parse_client_key); parseacl defaultacl = new parseacl(); defaultacl.setpublicreadaccess(true); parseacl.setdefaultacl(defaultacl, true); pushservice.setdefaultpushcallback(this, mainactivity.class); parseinstallation.getcurrentinstallation().getinstallationid(); parseinstallation.getcurrentinstallation().saveinbackground();
and subscribe:
pushservice.subscribe(this, username, detail.class);
in manifest
above
<permission android:name="com.example.app.permission.c2d_message" android:protectionlevel="signature" /> <uses-permission android:name="com.example.app.permission.c2d_message" />
in application tag:
<receiver android:name="com.parse.parsebroadcastreceiver" > <intent-filter> <action android:name="android.intent.action.boot_completed" /> <action android:name="android.intent.action.user_present" /> <action android:name="act" /> </intent-filter> </receiver> <receiver android:name="com.app.example.pushreceiver" > <intent-filter> <action android:name="act" /> </action> </intent-filter> </receiver> <receiver android:name="com.parse.gcmbroadcastreceiver" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <action android:name="com.google.android.c2dm.intent.registration" /> <action android:name="act" /> <category android:name="com.example.app" /> </intent-filter> </receiver>
and each time when install, show error shown below.
03-10 12:18:48.555: e/parsecommandcache(12709): failed run command. 03-10 12:18:48.555: e/parsecommandcache(12709): com.parse.parseexception: @ least 1 id field (installationid,devicetoken) must specified in operation 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.parsecommand$3.then(parsecommand.java:348) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$10.run(task.java:452) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$1.execute(task.java:68) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.completeimmediately(task.java:448) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.continuewith(task.java:322) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.continuewith(task.java:333) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$8.then(task.java:385) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$8.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11.run(task.java:485) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$1.execute(task.java:68) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.completeaftertask(task.java:481) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$9(task.java:477) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$7.then(task.java:350) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$7.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.runcontinuations(task.java:514) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$5(task.java:510) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.trysetresult(task.java:569) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.setresult(task.java:603) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11$1.then(task.java:497) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11$1.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$10.run(task.java:452) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$1.execute(task.java:68) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.completeimmediately(task.java:448) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$8(task.java:444) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$6.then(task.java:315) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$6.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.runcontinuations(task.java:514) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$5(task.java:510) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.trysetresult(task.java:569) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.setresult(task.java:603) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11$1.then(task.java:497) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11$1.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$10.run(task.java:452) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$1.execute(task.java:68) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.completeimmediately(task.java:448) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.continuewith(task.java:322) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.continuewith(task.java:333) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$11.run(task.java:489) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$1.execute(task.java:68) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.completeaftertask(task.java:481) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$9(task.java:477) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$7.then(task.java:350) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$7.then(task.java:1) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.runcontinuations(task.java:514) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task.access$5(task.java:510) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.trysetresult(task.java:569) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$taskcompletionsource.setresult(task.java:603) 03-10 12:18:48.555: e/parsecommandcache(12709): @ com.parse.task$3.run(task.java:228) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.executors$runnableadapter.call(executors.java:422) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.futuretask.run(futuretask.java:237) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$201(scheduledthreadpoolexecutor.java:152) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor.java:265) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) 03-10 12:18:48.555: e/parsecommandcache(12709): @ java.lang.thread.run(thread.java:841)
i want register 1 time on device. there should not issue if app installed multiple time in device.please me, in advance.
in case samsung tab 3 registers twice same uniqueid. uniqueid marked unique column in parse db? or should make unique? if yes, how?
i think mukul has provided great cloud code issue
here
parse.cloud.beforesave(parse.installation, function(request, response) { parse.cloud.usemasterkey(); var query = new parse.query(parse.installation); query.equalto("owner", request.user); query.equalto("uniqueid", request.object.get("uniqueid")); query.first().then(function(duplicate) { if (typeof duplicate === "undefined") { console.log("duplicate not exist,new installation"); response.success(); } else { console.log("duplicate exist..trying delete " + duplicate.id); duplicate.destroy().then(function(duplicate) { console.log("successfully deleted duplicate"); response.success(); }, function() { console.log(error.code + " " + error.message); response.success(); }); } }, function(error) { console.warn(error.code + error.message); response.success(); }); });
note owner username or primary key think u can use.
here's link of same better explanation mukul https://www.parse.com/questions/check-for-duplicate-installations-of-same-user-on-re-installation-of-app
Comments
Post a Comment