App user to enable/disable Pushes option

Comments

1 comment

  • Avatar
    Alexander Spotar

    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();
    

Please sign in to leave a comment.