Hi, we want to allow our users an option to enable/disable if the want to get our push notifications from us. Does your API allow for this on Android? I cant seem to find it if it does. Thanks, Darren.

asked 14 Mar '14, 13:50
dmac's gravatar image

dmac
113

Locate the code below in your pushmanager:

PushManager pushManager = new PushManager(this, "Pushwoosh app id", "Google app id");
pushManager.onStartup(this);

and replace it with:

PushManager pushManager = new PushManager(this, "Pushwoosh app id", "Google app id");

if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("push_enabled", true))
{
    pushManager.onStartup(this);
}
else
{
    pushManager.unregister();
}

On the application settings screen (or any other place where you'd like to put the Push ON/OFF toggle), you can use the following code:

PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("push_enabled", < true or false >).commit();
permanent link
answered 20 Mar '14, 07:56
Alex%20Spotar's gravatar image

Alex Spotar
3.6k6

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×326
×14

question asked: 14 Mar '14, 13:50

question was seen: 1,726 times

last updated: 20 Mar '14, 07:56