avivais / phonegap-parse-plugin

Phonegap 3.0.0 plugin for Parse.com push service
195 stars 315 forks source link

getInstallationObjectId - Asynchronicity issue - Help & Idea #58

Open nobesio opened 9 years ago

nobesio commented 9 years ago

Hey, I was trying to get my Installation Object Id using the method getInstallationObjectId but I am having some problems. If I run it as soon as the app runs it returns null, but what is strange is that the method getInstallationId returns the expected value just right after the app opens without problems. I need the object id in order to make an update in the object and a few more attributes to the installation, like for example the user.

Can someone please help me find the solution?

PD: It would be really cool to have a method call "addAtributeToInstallation" (or something similar) and that given the name of the attribute and the attribute values, it stores it without having to make any HTTP request outside the plugin.

Something like this: window.parsePlugin.addAtributeToInstallation("color, "blue");

Thanks you all very much! Hope someone can help me :)

fastrde commented 9 years ago

Workaround for that issue

var objectIdInterval = setInterval(function() {
              parsePlugin.getInstallationObjectId(function(id) {
                if (id != null) {
                  console.log(id);

                  clearInterval(objectIdInterval);
                  onIdReceivedFunction(id);
                }
              });
            }, 200);
ricardocarvalh0 commented 8 years ago

I have the same problem. getInstallationObjectId() always returns null while getInstallationId() works fine. Am i just missing something?