I have created an app in iOS that uses Parse to store data and also uses Parse Push for messaging between users. I am now converting the app to Android and trying to use the same Parse backend for both. I am successfully uploading/downloading data and I can even send a message from an Android user to a iOS user, but I can't get my Android device to receive messages. The underlining problem seems to be that I can't get the installation to work. I am calling this block of code from my onCreate function:
Parse.enableLocalDatastore(this);
Parse.initialize(this, "id1", "id2");
ParsePush.subscribeInBackground("", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
ParseInstallation.getCurrentInstallation().saveInBackground();
After calling this code I check for a new installation in the database, but nothing ever shows up. It seems as though ParseInstallation.getCurrentInstallation().saveInBackground(); is not doing anything. Am I missing something?
the object associated with the installation on the given device does not have a row in the parse installation table, this is why you are getting the error, there are 2 possible solutions to this problem :
This method must be called before you call Parse.initialize...
public static boolean deleteInstallationCache(Context context) {
boolean deletedParseFolder = false;
File cacheDir = context.getCacheDir();
File parseApp = new File(cacheDir.getParent(),"app_Parse");
File installationId = new File(parseApp,"installationId");
File currentInstallation = new File(parseApp,"currentInstallation");
if(installationId.exists()) {
deletedParseFolder = deletedParseFolder || installationId.delete();
}
if(currentInstallation.exists()) {
deletedParseFolder = deletedParseFolder && currentInstallation.delete();
}
return deletedParseFolder;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With