Every one I am using the parse service for push notification in my app. but it register all time when i re-install the app in one device.Then problem is that,one device rece
I was also facing this issue. I sort of solved it by calling the below method in my Activity's onCreate()
/**
* Initialize Push Messaging Service and subscribe to all-users channel
*/
private void initParsePushMessaging() {
ParseInstallation parseInstallation = ParseInstallation
.getCurrentInstallation();
//You might skip this if
if (ParseUser.getCurrentUser() != null) {
parseInstallation.put("user",
ParseUser.getCurrentUser());
}
if (parseInstallation.getObjectId() != null)
parseInstallation.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
PushService.subscribe(getApplicationContext(),"channel_name",
MainHomeActivity.class);
}
});
}
Even though it didn't completely solve my problem but now my app doesn't hang and no more ANR's due to this Parse implementation. If i re install an app and run it now then the app creates a new installation record and remove's the last one. The only problem is that the channel_name is not subscribed on this run but on the next run the channel are successfully subscribed.