Skip to content

Instantly share code, notes, and snippets.

@rnystrom
Created July 2, 2013 19:52
Show Gist options
  • Select an option

  • Save rnystrom/5912541 to your computer and use it in GitHub Desktop.

Select an option

Save rnystrom/5912541 to your computer and use it in GitHub Desktop.
// get user settings
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
boolean doUpdates = sharedPref.getBoolean(SettingsActivity.UPDATES_KEY, true);
boolean doRally = sharedPref.getBoolean(SettingsActivity.RALLY_KEY, true);
boolean doLeads = sharedPref.getBoolean(SettingsActivity.LEAD_KEY, true);
// subscribe to channels based on user settings
if (doUpdates) PushService.subscribe(this, Update.UPDATES_NOTIFICATION_KEY, UpdatesDetail.class);
if (doRally) PushService.subscribe(this, Update.RALLY_NOTIFICATION_KEY, UpdatesDetail.class);
if (doLeads) PushService.subscribe(this, Update.LEAD_NOTIFICATION_KEY, UpdatesDetail.class);
// channel for special users
if (ParseUser.getCurrentUser() != null && ParseUser.getCurrentUser().getBoolean(NJUser.IS_P2P_KEY)) {
PushService.subscribe(this, "p2p", MainActivity.class);
}
// channel for development & testing
PushService.subscribe(this, "development", MainActivity.class);
// default activity for push callback
PushService.setDefaultPushCallback(this, MainActivity.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment