phonegap icon indicating copy to clipboard operation
phonegap copied to clipboard

How to allow users to toggle notifications on or off?

Open jamminjames opened this issue 7 years ago • 1 comments

I am trying to create a toggle button to allow users of our app to control notifications. I have this, but it's not working:

$(document).on("pagecreate", "#about", function () {

$('#flipnotify').on('change', function() {
       $(this).val() == "off" ? play_int() : play_on();
});

function play_int() {
    $('#flipnotify').val();
        window.plugins.PushbotsPlugin.toggleNotifications(false);
}

function play_on() {
    $('#flipnotify').val();
        window.plugins.PushbotsPlugin.toggleNotifications(true);
}

});

The html is a jquery mobile flipswitch:

		<label for="flipnotify">Toggle Notifications On/Off:</label>
			<select name="flipnotify" id="flipnotify" data-role="flipswitch">
				<option value="on">On</option>
				<option value="off">Off</option>
			</select>
		</div>

Any help getting this to work would be appreciated.

jamminjames avatar Mar 03 '18 01:03 jamminjames

@jamminjames Most people would implement this server-side, i.e. keep track of users that has disabled push and don't send them any.

sandstrom avatar Oct 14 '19 12:10 sandstrom